wasm: add DialogExec hack/warning to event dispatcher

Show the warning (and call emscripten_sleep) for the standard
build, but not for the asyncify build.

Change-Id: I695a580ea60897872beee6fa2b6ae70acb9e7dcf
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
bb10
Morten Johan Sørvig 2021-08-18 14:34:55 +02:00
parent 04fd894400
commit a72066f449
2 changed files with 19 additions and 0 deletions

View File

@ -206,6 +206,9 @@ bool QEventDispatcherWasm::processEvents(QEventLoop::ProcessEventsFlags flags)
qCDebug(lcEventDispatcher) << "QEventDispatcherWasm::processEvents flags" << flags
<< "pending events" << hasPendingEvents;
if (flags & QEventLoop::DialogExec)
handleDialogExec();
if (!(flags & QEventLoop::ExcludeUserInputEvents))
pollForNativeEvents();
@ -361,6 +364,21 @@ void QEventDispatcherWasm::wakeUp()
emscripten_async_call(&QEventDispatcherWasm::callProcessEvents, this, 0);
}
void QEventDispatcherWasm::handleDialogExec()
{
#if !QT_HAVE_EMSCRIPTEN_ASYNCIFY
qWarning() << "Warning: dialog exec() is not supported on Qt for WebAssembly in this"
<< "configuration. Please use show() instead, or enable experimental support"
<< "for asyncify.\n"
<< "When using exec() (without asyncify) the dialog will show, the user can interact"
<< "with it and the appropriate signals will be emitted on close. However, the"
<< "exec() call never returns, stack content at the time of the exec() call"
<< "is leaked, and the exec() call may interfere with input event processing";
emscripten_sleep(1); // This call never returns
#endif
// For the asyncify case we do nothing here and wait for events in waitForForEvents()
}
void QEventDispatcherWasm::pollForNativeEvents()
{
// Secondary thread event dispatchers do not support native events

View File

@ -90,6 +90,7 @@ private:
bool isMainThreadEventDispatcher();
bool isSecondaryThreadEventDispatcher();
void handleDialogExec();
void pollForNativeEvents();
bool waitForForEvents();
static void callProcessEvents(void *eventDispatcher);