diff options
author | Piotr Wiercinski <[email protected]> | 2025-03-31 15:47:09 +0200 |
---|---|---|
committer | Piotr Wiercinski <[email protected]> | 2025-04-09 13:58:46 +0200 |
commit | b8ff842ace2b4bd9f7dc6a10e71e6545bd66a138 (patch) | |
tree | 87fab274a7f9cce5eb69127c52e79af592267e97 | |
parent | d139d22f7e70c8f1842eb2befccb9772d92458e1 (diff) |
wasm: Fix use after delete of QWasmSuspendResumeControl
m_inputContext and other fields depends on the lifetime
of m_suspendResume, but the latter gets destroyed first.
Make sure that m_suspendResume is initialized first.
Fixes: QTBUG-135378
Change-Id: Ifa2d58ec06a1f832549478bece3a8f651276ac8f
Reviewed-by: Morten Johan Sørvig <[email protected]>
-rw-r--r-- | src/plugins/platforms/wasm/qwasmintegration.cpp | 4 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qwasmintegration.h | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp index 2798b06f2bd..e3cdf11fa27 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.cpp +++ b/src/plugins/platforms/wasm/qwasmintegration.cpp @@ -89,13 +89,13 @@ EMSCRIPTEN_BINDINGS(qtQWasmIntegraton) QWasmIntegration *QWasmIntegration::s_instance; QWasmIntegration::QWasmIntegration() - : m_fontDb(nullptr) + : m_suspendResume(std::make_shared<QWasmSuspendResumeControl>()) // create early in order to register event handlers at startup + , m_fontDb(nullptr) , m_desktopServices(nullptr) , m_clipboard(new QWasmClipboard) #if QT_CONFIG(accessibility) , m_accessibility(new QWasmAccessibility) #endif - , m_suspendResume(std::make_shared<QWasmSuspendResumeControl>()) // create early in order to register event handlers at startup { s_instance = this; diff --git a/src/plugins/platforms/wasm/qwasmintegration.h b/src/plugins/platforms/wasm/qwasmintegration.h index 50bed742c70..045f00de4dc 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.h +++ b/src/plugins/platforms/wasm/qwasmintegration.h @@ -95,6 +95,9 @@ private: QWasmScreen *wasmScreen; }; + // m_suspendResume should be created first and destroyed early as other fields depend on it + std::shared_ptr<QWasmSuspendResumeControl> m_suspendResume; + mutable QWasmFontDatabase *m_fontDb; mutable QWasmServices *m_desktopServices; mutable QHash<QWindow *, QWasmBackingStore *> m_backingStores; @@ -107,7 +110,6 @@ private: static QWasmIntegration *s_instance; QWasmInputContext *m_wasmInputContext = nullptr; - std::shared_ptr<QWasmSuspendResumeControl> m_suspendResume; #if QT_CONFIG(draganddrop) std::unique_ptr<QWasmDrag> m_drag; |