From a9bb94e28a6757719a2e833c9d3ca17b3205283b Mon Sep 17 00:00:00 2001 From: Jan-Marek Glogowski Date: Wed, 17 Nov 2021 10:29:24 +0100 Subject: VCL fix shutdown when run via system loop Adds DoQuit and SAL_USE_SYSTEM_LOOP to complement DoExecute. Makes it easier to switch between a LO with and without nested event processing. Unfortunatly the recovery dialogs run outside of Application::Execute(), so this currently also disables recovery handling. Follow-up (and no more Emscripten-specific) change to commit 93133585b5b52e38defc3162eeb1e7704dceafcb ("WASM optionally run any app via system loop"). Change-Id: I1b622065d7fa0c5ad03a7c7daaf8241dcc3f09a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128717 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski --- vcl/qt5/QtInstance.cxx | 19 ++++++++++++------- vcl/qt5/QtTimer.cxx | 11 ++++++----- 2 files changed, 18 insertions(+), 12 deletions(-) (limited to 'vcl/qt5') diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx index a03b71e46bd2..a52f6529c3bc 100644 --- a/vcl/qt5/QtInstance.cxx +++ b/vcl/qt5/QtInstance.cxx @@ -259,6 +259,8 @@ QtInstance::QtInstance(std::unique_ptr& pQApp, bool bUseCairo) #ifndef EMSCRIPTEN m_bSupportsOpenGL = true; +#else + ImplGetSVData()->maAppData.m_bUseSystemLoop = true; #endif } @@ -726,13 +728,16 @@ std::unique_ptr QtInstance::CreateQApplication(int& nArgc, char** bool QtInstance::DoExecute(int& nExitCode) { -#ifdef EMSCRIPTEN - nExitCode = m_pQApplication->exec(); - return true; -#else - (void)nExitCode; - return false; -#endif + const bool bIsOnSystemEventLoop = Application::IsOnSystemEventLoop(); + if (bIsOnSystemEventLoop) + nExitCode = QApplication::exec(); + return bIsOnSystemEventLoop; +} + +void QtInstance::DoQuit() +{ + if (Application::IsOnSystemEventLoop()) + QApplication::quit(); } extern "C" { diff --git a/vcl/qt5/QtTimer.cxx b/vcl/qt5/QtTimer.cxx index 6568ca8ac1b8..1a34213977dc 100644 --- a/vcl/qt5/QtTimer.cxx +++ b/vcl/qt5/QtTimer.cxx @@ -42,11 +42,12 @@ QtTimer::QtTimer() void QtTimer::timeoutActivated() { SolarMutexGuard aGuard; -#ifdef EMSCRIPTEN - const ImplSVData* pSVData = ImplGetSVData(); - assert(pSVData->mpDefInst); - static_cast(pSVData->mpDefInst)->DispatchUserEvents(true); -#endif + if (Application::IsOnSystemEventLoop()) + { + const ImplSVData* pSVData = ImplGetSVData(); + assert(pSVData && pSVData->mpDefInst); + static_cast(pSVData->mpDefInst)->DispatchUserEvents(true); + } CallCallback(); } -- cgit