summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qeventdispatcher_wasm.cpp
Commit message (Collapse)AuthorAgeFilesLines
* wasm: back out of calling onLoaded at first frameMorten Sørvig2024-04-221-4/+5
| | | | | | | | | | | | | | | Qt and application code expects that QScreen geometry should be available early in main(), after the QApplication constructor returns. This is not the case if onLoaded is called at later point in time, since the container element for the screen is typically made visible when onLoaded is called, and does not have valid geometry before. Change-Id: I62d87f01fce1cd601e7a70d842e22a61814c9db7 Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io> Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
* QEventDispatcher*: port the Unix dispatchers to V2Thiago Macieira2024-03-131-12/+11
| | | | | | | | | | | They're all ported in one go because all the changes are the same and they all rely on QTimerInfoList. The changes are: - use Qt::TimerId to uniquely identify timer IDs - use Duration (nanoseconds) to specify the timer interval - rename registeredTimers() to timersForObject(), which is const Change-Id: I83dda2d36c904517b3c0fffd17b52958767d8a68 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QTimerInfo: store nanoseconds instead of millisecondsThiago Macieira2024-03-131-2/+3
| | | | | | | | | | | | | | No change in behavior, other than the ability for the precise timers to be even more precise. There's a reduction in the stored interval range from 292 million years to 292 years, but there's no change in behavior because the timeout is stored as a steady_clock::time_point, which is nanoseconds with libstdc++ and libc++. Now, if there's an overflow, it'll happen on the call to registerTimer() instead of inside the calculation of the wake-up. Change-Id: I83dda2d36c904517b3c0fffd17b3d1f2d9505c1c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* wasm: fix onLoaded delay functionalityMorten Sørvig2024-02-081-10/+17
| | | | | | | | | | | | | | | | | | | | | | | onLoaded and the initial expose/paint should be sequenced such that onLoaded is fired first, followed by the expose. This makes sure that we don't spend any time on painting frames before Qt is completely initialized. Add a "requestUpdateHold" mode to QWasmCompositor (initially on) which disables requestUpdate calls, as well as releaseRequestUpdateHold() which enables requestUpdate calls again. This is a one-way transition; the mode can't be enabled again. This amends commit f2e22774 which implemented the concept of startup tasks, where onLoaded can be delayed until for instance font loading has been completed. After this commit the expose event and initial commit will be delayed as well. Change-Id: Icc784306726174fbabe8785d54485860e968745a Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
* Fix stub qt_jspi_resume_js() return valueMorten Sørvig2024-01-151-1/+2
| | | | | | | | Return bool for the dynamic linking stub, like the actual function. Change-Id: I0e0daeac3d647055fecb7930f9ed8e6f9f574bb5 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: delay "qtLoaded" qtloader.js eventMorten Sørvig2023-12-181-0/+42
| | | | | | | | | | | | | | | | | | | | | | | Currently we send qtLoaded in response to Emscripten onRuntimeInitialized, which is sent just before or at the time main() is called. This can be too early if Qt (app) initialization is not instantaneous, in which case we risk displaying a blank page in between hiding the loading screen and showing the application. Change this to send qtLoaded when QCoreApplication has finished its constructor and the event loop is running. Also add the possibility of registering startup tasks which can delay sending qtLoaded further. We now require a QCoreApplication (or a subclass) instance for the qtLoaded event. onRuntimeInitialized can be used as a replacement if anyone needs the previous behavior. Change-Id: I9298e881d2909aac4040c5f2068e6c7d196196cc Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: manage wakeUp state correctlyMorten Sørvig2023-11-271-1/+15
| | | | | | | | | | | | | | | | | | | | | | | We were losing wakeups in cases where wakeUp() was called during processPostedEvents(), since wait() was unconditionally resetting m_wakeUpCalled. Fix this by setting m_wakeUpCalled to false before processing posted events, and then checking if it's still false before waiting. We don't hold the mutex while processing events so that can still race with wakeUp() calls, but this should now be harmless since at worst we'll spin and check for posted events one extra time before waiting. Pick-to: 6.6 6.5 Fixes: QTBUG-118416 Change-Id: I0183747c4d1f128bb6a46ba9c68f4eeb4d35a138 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* wasm: Fix UB in QEventDispatcherPiotr Wierciński2023-10-191-1/+0
| | | | | | | | Calling std::mutex::try_lock() when the mutex is already owned by the thread casuses undefined behavior. Change-Id: I024ced271cad8a034bebf80b48e31e7e7461c560 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Fix problem with queued signals on main threadMikolaj Boc2023-10-131-3/+9
| | | | | | | | | | | Queued signals from main thread were not handled if enqueued on a different thread. This is because qt_jspi_can_resume_js was called on a thread (worker), where the Module object does not have the property used for determining whether JSPI is suspended. Change-Id: Icbc4dbfcf46c1091eb71b23c7de50760c8a339ae Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: simplify calling runOnMainThread()Morten Sørvig2023-09-131-36/+30
| | | | | | | | | | | | | | | Add a static runOnMainThread() function to QEventDispatcherWasm which looks at QT_CONFIG(thread) and calls the correct qstdweb overload. Then, we don't have to use a #define to enable or disable the proxyingQueue argument. Use the <void> version of qstweb::runTaskOnMainThread, like before the 141f0ca33 change. Change-Id: Id8324a17c27ffce8db7acf235ad4c9e465790e0b Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
* wasm: don't crash if app is deleteLater()edMorten Sørvig2023-09-071-0/+5
| | | | | | | | | | | | | | | | | We check for a valid event dispatcher when waking up, but there was no check after processing queued events, and processEvents() would continue with a stale this pointer if one of the queued events happened to delete the application object. Fix this by checking if this is still a valid pointer after processing events. Fixes: QTBUG-116330 Pick-to: 6.6 6.5 Change-Id: Ic4d91298986847e6095ce9daea51a4b974106c06 Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Move runTaskOnMainThread to qstdweb_p.h, use it in WASM dispatcherMikolaj Boc2023-08-251-38/+36
| | | | | | | | This unifies the approach to running sync tasks (possibly with a return value) on the main thread. Change-Id: I2a05c4f40115a79dbf03c03fa8d8db34124884dc Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
* Add clang-format guards around EM_JS code in WASM dispatcherMikolaj Boc2023-08-221-0/+4
| | | | | | | This is to avoid it formatting lambda => as = > Change-Id: Ie9cb19c8594cab6fe33910f52800fc1b6207a6f6 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Do not call processEvents async with JSPI enabled on WASMMikolaj Boc2023-08-161-1/+3
| | | | | | | | | | | | With JSPI, the main dispatcher loop is not exited and processEvents should not be called, as events will get processed after the thread has been unsuspended. processEvents posted with emscripten_async_call causes stack corruption. Fixes: QTBUG-115959 Change-Id: Ibccccbf54f18df2d03f0c5e817c3a7102e96c9ed Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* QTimerInfoList: change timerWait() to return std::optional<ms>Ahmad Samir2023-08-111-11/+7
| | | | | | | | | | | | | QEventDispatcherGlib: it used the out-parameter timespec to set a timeout in milliseconds, making timerWait() return milliseconds is more straightforward. Also timerWait() returns the time rounded to milliseconds, so the code in QEventDispatcherGlib that rounded up the timespec::tv_nsec part was no-op, tv_nsec was always 0 IIUC. In QEventDispatcherGlib, guard against overflow with qt_saturate. Change-Id: Ie6f78374d00cbe8a6adf7b50ed67c8c86ab4d29d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Resolve JSPI-related build problems on shared buildsMikolaj Boc2023-07-271-0/+21
| | | | | | | | | | Added dummy definitions of missing JSPI functions in qeventdispatcher_wasm.cpp. Fixes: QTBUG-115505 Change-Id: Ifb63960ef980905834808dddaf399adb2ca843cb Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Core: include mocsMårten Nordheim2023-07-071-0/+2
| | | | | Change-Id: If116c090450836007dca826fba1754058fc754c0 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* wasm: introduce virtual processPostedEvents()Morten Sørvig2023-07-041-11/+12
| | | | | | | | | | | | | | | Don't re-use processEvents() for the case where we get a callback from the native event loop and want to send events. This makes it clearer that these are two different cases. Align with the Core Foundation event dispatcher where processPostedEvents() is virtual and is overridden by the Gui event dispatcher to send window system events. Pick-to: 6.6 Change-Id: I3ea9c55c1d9c03195c1937c4dcc0e5b689e15448 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* wasm: don't use on qGlobalPostedEventsCount()Morten Sørvig2023-07-031-11/+8
| | | | | | | | | | | | | | | | There is no guarantee that it will return 0 after one call to sendPostedEvents(), since more events may have been posted during that call. This can in turn cause infinite looping since the wait() isn't called. Move sendPostedEvents to the top of processEvents() to make sure we send events before waiting, in line with the implementation for the other event dispatchers. Pick-to: 6.5 6.6 Fixes: QTBUG-112893 Change-Id: Iba7d87cf1c08cd302884782cb135d758afeb9e4b Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Don't simulate main loop with JSPIMikolaj Boc2023-06-171-4/+8
| | | | | | | | | This is not needed, as main loop just works with awaited calls thanks to JS suspender objects with JSPI enabled. Fixes: QTBUG-114651 Change-Id: I94e187953ac8cec5c999f1b02508efecc19641f6 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Adapt WASM event dispatcher to use JSPI, if availableMikolaj Boc2023-06-121-7/+58
| | | | | | | | | | | | | | | | | Detect if JSPI is available and suspend the execution of the program if so, instead of using 'bare' asyncify. For now: 1) This works only with emscripten 3.1.36 with mboc-qt patches from emscripten repo 2) Apps have to specify the following linker options: -sDYNCALLS=1 -sASYNCIFY=2 -sASYNCIFY_EXPORTS=dynCall_* Fixes: QTBUG-113570 Change-Id: Ide7c51e36990df7e20c6c9b5a218366cb0db100e Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* QTimerInfoList/Unix: use chrono::steady_clock::time_pointAhmad Samir2023-06-101-12/+16
| | | | | | | | I.e. use chrono first, see linked task for more details. Task-number: QTBUG-110059 Change-Id: Ie0908f9446957d4383fb7a70b67c16b78605a0f3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QEventDispatcher/WASM: fix a lambda nameAhmad Samir2023-05-151-3/+3
| | | | | | | | | It's returning milliseconds not nanoseconds. Change-Id: I7dbc3f4043694b6ddf87c6ad9e4d20d3a9af0fd1 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
* wasm: use emscripten::ProxyingQueueMorten Sørvig2023-02-281-2/+11
| | | | | | | | | | | | | | Use ProxyingQueue for proxing calls from secondary threads to the main thread. This replaces the previous usage of the private emscripten_async_run...() API. Keep the existing "trampoline" which in addition proxies using a JavaScript zero timer. This makes sure that the proxied call is made with a clean stack, and not e.g. while the main thread is waiting on a mutex. Change-Id: I66cfdc2cf4bc733b1732973677c2ae46d85c8e7c Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
* wasm: Fix secondary thread event processingMorten Sørvig2023-01-061-7/+3
| | | | | | | | | | | | | | | | Fix test failure in WasmEventDispatcherTest::postEventSecondaryThread() Revert to using qGlobalPostedEventsCount() for determining pending events state, but move the final check to after sending posted events. Also remove a superfluous check. This partially reverts/amends cc60d706. Task-number: QTBUG-109066 Pick-to: 6.5 Change-Id: If4f437ce9379282c3d60b0272845a975794883de Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Fix event dispatching on WASMMikolaj Boc2022-12-161-5/+16
| | | | | | | | | | | | 1) Check only for the events that the dispatcher is able to process, otherwise it enters an endless loop 2) Take care to run the correct wake up callback with Asyncify.handleSleep Fixes: QTBUG-109066 Change-Id: I10d29d18962c3e438e56712e1f43ecadedb6205c Pick-to: 6.5 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Introduce centralized means of checking for asyncifyMikolaj Boc2022-09-231-15/+8
| | | | | | | | The new function has an advantage of not requring EM_JS. Change-Id: Ib9ad0e6b59cfe2e6864697a14b5cfdb39f62af2d Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Clear the timer target time when stopping a timer on WASMMikolaj Boc2022-09-061-0/+1
| | | | | | | | | | | | | | | | | | Not clearing the target time makes the subsequently created timers not get their time ticks, as no actual timeout will be registered as the dispatcher wrongly assumes there will be a tick fired, which there isn't. Since there are no updates, the WASM compositor enters an infinite window update loop where it requests an update on a window, and the window requests an update on it, getting the update request back due to an animation running forever. Pick-to: 6.4 6.4.0 Fixes: QTBUG-105347 Fixes: QTBUG-102004 Fixes: QTBUG-104518 Fixes: QTBUG-106153 Change-Id: I14b8dd08df81852e28e8527545c8530e0656990d Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: disable asyncify for non-static buildsMorten Sørvig2022-08-241-0/+23
| | | | | | | | | | The asyncify support in the event loop currently uses EM_JS, which Emscripten does not support using from side modules. Change-Id: I5f961d9cd12f7b1b6cc1c2382b807a1da2918725 Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
* wasm: streamline the exec warningMorten Sørvig2022-08-171-6/+2
| | | | | | | | | State the problem and suggest possible solutions for the app developer. Pick-to: 6.4 Change-Id: I0484c4eb31020ec0016005f43f910f32a319b850 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* wasm: include asyncify support unconditionallyMorten Sørvig2022-08-171-29/+35
| | | | | | | | | | | | | | | | | | | Emscripten's option for enabling asyncify (-sASYNCIFY) is a link-time option, which means there is no requirement to have a separate asyncify build, at least for static builds. Replace the current QT_HAVE_EMSCRIPTEN_ASYNCIFY compile-time option with a run-time option which checks if the asyncify API is available. Keep support for configuring with "-device-option QT_EMSCRIPTEN_ASYNCIFY=1" for backwards compatibility and for the use case where want asyncify support to be on by default for a given Qt build. Enable asyncify for the asyncify_exec example. Pick-to: 6.4 Change-Id: I301fd7e2d3c0367532c886f4e34b23e1093646ad Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* wasm: remove dead qt_asyncify_yield() codeMorten Sørvig2022-08-171-29/+0
| | | | | | | | | | | | | The call to this function was behind a broken #define and was never enabled. It also does not work, so remove it. This means that calling processEvents() in a loop (as opposed to calling exec()) most likely does not work either, which is something we want to revisit. Pick-to: 6.4 Change-Id: I90802a69d3a48e7f2b5d0b657d89452c09d9571a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix typos in docs and commentsKai Köhne2022-06-151-3/+3
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* wasm: add support for blocking socketsMorten Johan Sørvig2022-06-021-51/+161
| | | | | | | | | | | | | | | | | | | | | Add support for blocking sockets on secondary threads and on the main thread with asyncify. This extends the support for websockify tunneled TCP sockets, which was previously limited to async sockets on the main thread. Blocking sockets support is implemented by emulating select() on top of emscripten's socket notification support. This is requires synchronization between the blockee threads and the main thread, since we get socket notification callbacks on the main thread. The synchronized state is held in g_socketState where the main thread registers socket readiness state and blocking threads register themselves. Blocking using asyncify on the main thread is similar to blocking on a secondary thread, with the exception that the main thread suspends with qt_asyncify_suspend() instead of waiting on a wait condition. Change-Id: Idb5a493644e1e6634057dc2f64f2e99e82e3c01e Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: refactor event dispatcher wait logicMorten Sørvig2022-06-011-83/+137
| | | | | | | | | | | | | | | | | | | | | We support blocking the event dispatcher thread in two cases: - secondary threads: wait on a wait condition - main thread: asyncify suspend Create abstraction which implements both cases under a common API: bool QEventDispatcherWasm::wait(int timeout) void QEventDispatcherWasm::wakeUpDispatcherThread() Make QEventDispatcherWasm::wakeUp() use the new API. Also refactor the runOnMainThread functionality to provide several variants - runAsync(fn): makes an async call on the main thread, from the main thread. - runOnMainThread(fn): runs fn on the main thread, synchronously if called from the main thread. - runOnMainThreadAsync(fn): runs a fn on the main thread, always asynchronously Change-Id: Ia6ac21a162e6b8ea2d71bacf6085beb9567588b5 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: don't enable specialHTMLTargets by defaultMorten Sørvig2022-06-011-0/+1
| | | | | | | | | | | | | | | | | | Adding specialHTMLTargets to EXPORTED_RUNTIME_METHODS carries the obligation to actually use it as well; failing to do so makes Emscripten stop with a reference error on startup. However, we can't guarantee that Qt will use it in all cases. The current usage depends on QGuiApplication being used. Application code could be using QCoreApplication, or no application object at all. Detect if specialHTMLTargets is present instead, and then enable the code paths which uses it if that's the case. This means that apps which want to use e.g. multiple browser windows can opt into support by making sure EXPORTED_RUNTIME_METHODS contains specialHTMLTargets. Change-Id: I81105aa01946602fcf593f170e305d7dc9bad3be Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Remove manual declarations of qGlobalPostedEventsCount()Marc Mutz2022-05-181-1/+1
| | | | | | | | | ... in favor of including qabstracteventdispatcher_p.h, where needed. Keeps the code DRY. Change-Id: I5bee2e653cb29ffac2601ff03c952a4b3adbdb9c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Apply Q_CONSTINIT across the codebaseMarc Mutz2022-03-291-3/+4
| | | | | | | | | Still not complete. Just grepping for static and thread_local. Task-number: QTBUG-100486 Change-Id: I90ca14e8db3a95590ecde5f89924cf6fcc9755a3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* wasm: add virtual processWindowSystemEvents()Morten Johan Sørvig2021-12-231-0/+6
| | | | | | | | | | The QtCore event dispatcher will be used from QtGui as well. Add virtual function where window system events processing can be added. Pick-to: 6.3 Change-Id: Ia6eda9ae18b2e91189ef9f60b6621d19a83313de Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: implement socket notifier supportMorten Johan Sørvig2021-12-151-4/+135
| | | | | | | | | | | | Implement socket notifier support using Emscripten’s socket callbacks. This is sufficient for supporting non-blocking (tunneled) TCP and UDP sockets on the main thread. Change-Id: Ib9ee2698d029fb94d954c6872f8e118b0aa15499 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: fix native timer update for the no-timer caseMorten Johan Sørvig2021-11-111-2/+10
| | | | | | | | | | | | | QTimerInfoList::timerWait() does not update the timespec out argument if there are no active timers, which caused the current code to calculate an arbitrary toWaitDuration. Instead use the timerWait() return value, and clear any native timers if there are no active Qt timers. Pick-to: 6.2 Change-Id: I7d5ec4c2930000bece6f6ea6c63e76f4df543b04 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: make timers work for the new event dispatcherMorten Johan Sørvig2021-11-111-3/+0
| | | | | | | | | | Don’t exit from the timer callback if there is no main thread event dispatcher, since it could be that the main thread event dispatcher is of the old event dispatcher type. Pick-to: 6.2 Change-Id: Ibb7a34a99e2001b52d2a985022f5baa7cd2152bf Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: enable event dispatcher asyncify supportMorten Johan Sørvig2021-11-041-22/+8
| | | | | | | | | | | | | | | | | | | | | Misc. fixes, including: Fix a couple of typos in the JavaScript code. Also, macros- within-macros don’t work, (without resorting to preprocessor token pasting), so remove the debug output for now. Limit the exec() “simulateInfiniteLoop” workaround to top-level application exec() only. This way, asyncify can be used for nested QEventLoop::exec() calls. (Emscripten supports one level of suspend only, so we don’t want to use that for the top-level exec(), but instead use it for dialogs and such). Use the new QEventLoop::ProcessEventsFlag::ApplicationExec enum value to detect the exec() call type. Change-Id: Ic702bfc31faf2e9f84ac5d3ccf43d067c5c61bf0 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* QEventDispatcherWasm: Fix typo in debug messageJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 6.2 Change-Id: I183de5fd477b9529dd5272c88a196b9bebf4ab66 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* corelib: Fix typos in source code commentsJonas Kvinge2021-10-121-3/+3
| | | | | | Pick-to: 6.2 Change-Id: Ic78afb67143112468c6f84677ac88f27a74b53aa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* wasm: fix runOnMainThread()Morten Johan Sørvig2021-10-011-6/+10
| | | | | | | | | | | Calling emscripten_async_run_in_main_runtime_thread_() with a pointer to a static lambda was too clever, use an anonymous function as callback instead. Pick-to: 6.2 Task-number: QTBUG-94344 Change-Id: I2d8a8b0ffc2dd1d02018aa5902550216d00f641d Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: limit exec() workarounds to the main threadMorten Johan Sørvig2021-09-301-4/+6
| | | | | | | | | | This fixes a bug where calling exec() on a secondary thread would make the thread exit. Task-number: QTBUG-94344 Pick-to: 6.2 Change-Id: I259c7ebbd53271609af88aca141d88c282cbcd34 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* QEventDispatcherWasm: handle EventLoopExecMorten Johan Sørvig2021-09-151-0/+18
| | | | | | | | | Call emscripten_set_main_loop like the old GUI event dispatcher did, with one difference that requestAnimationFrame updates are now no longer handled by the event dispatcher. Change-Id: If02d90ae9c45d7b38999567d733a237af842cded Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* wasm: add DialogExec hack/warning to event dispatcherMorten Johan Sørvig2021-09-081-0/+18
| | | | | | | | 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>