diff --git a/src/corelib/kernel/qeventdispatcher_wasm_p.h b/src/corelib/kernel/qeventdispatcher_wasm_p.h index 1a87ad3bb98..a66f67c3e34 100644 --- a/src/corelib/kernel/qeventdispatcher_wasm_p.h +++ b/src/corelib/kernel/qeventdispatcher_wasm_p.h @@ -52,6 +52,7 @@ public: void interrupt() override; void wakeUp() override; + static void runOnMainThreadAsync(std::function fn); static void socketSelect(int timeout, int socket, bool waitForRead, bool waitForWrite, bool *selectForRead, bool *selectForWrite, bool *socketDisconnect); protected: @@ -89,7 +90,6 @@ private: static void run(std::function fn); static void runAsync(std::function fn); static void runOnMainThread(std::function fn); - static void runOnMainThreadAsync(std::function fn); static QEventDispatcherWasm *g_mainThreadEventDispatcher; diff --git a/src/network/access/qnetworkreplywasmimpl.cpp b/src/network/access/qnetworkreplywasmimpl.cpp index be5b0f5f0ae..9c77d6881ea 100644 --- a/src/network/access/qnetworkreplywasmimpl.cpp +++ b/src/network/access/qnetworkreplywasmimpl.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -295,7 +296,10 @@ void QNetworkReplyWasmImplPrivate::doSendRequest() QByteArray destinationPath = dPath.toUtf8(); attr.destinationPath = destinationPath.constData(); - m_fetch = emscripten_fetch(&attr, request.url().toString().toUtf8()); + auto url = request.url().toString().toUtf8(); + QEventDispatcherWasm::runOnMainThreadAsync([attr, url]() mutable { + emscripten_fetch(&attr, url); + }); state = Working; }