diff options
author | Jøger Hansegård <joger.hansegard@qt.io> | 2024-01-27 19:58:48 +0100 |
---|---|---|
committer | Jøger Hansegård <joger.hansegard@qt.io> | 2024-02-21 19:19:26 +0100 |
commit | 751ca5e5bdb5918834af7c43d09f457a805d80f5 (patch) | |
tree | 32e6de314b974aabd60cdd1fe13e4404d79265f0 /src/corelib/kernel | |
parent | 974d791f3674031675113289f4bf09d4d21ac488 (diff) |
Assert if CoUninitialize is called on wrong thread
Every call to CoInitialize on a thread must be paired up with a call to
CoUninitialized on that same thread. QComHelper helps ensuring this, but
if an object using QComHelper is not created and destroyed on the same
thread, we end up in loosing this pairing.
This patch helps detecting such issues.
Task-number: QTBUG-121495
Change-Id: I07984437d1515d7ef61820d7152c339924b36e4b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qfunctions_win.cpp | 1 | ||||
-rw-r--r-- | src/corelib/kernel/qfunctions_win_p.h | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/kernel/qfunctions_win.cpp b/src/corelib/kernel/qfunctions_win.cpp index d5ce3e5894..048fdbc934 100644 --- a/src/corelib/kernel/qfunctions_win.cpp +++ b/src/corelib/kernel/qfunctions_win.cpp @@ -28,6 +28,7 @@ QComHelper::QComHelper(COINIT concurrencyModel) QComHelper::~QComHelper() { + Q_ASSERT(m_threadId == GetCurrentThreadId()); if (SUCCEEDED(m_initResult)) CoUninitialize(); } diff --git a/src/corelib/kernel/qfunctions_win_p.h b/src/corelib/kernel/qfunctions_win_p.h index 540405bd2f..ab5417f8a2 100644 --- a/src/corelib/kernel/qfunctions_win_p.h +++ b/src/corelib/kernel/qfunctions_win_p.h @@ -39,6 +39,7 @@ public: private: HRESULT m_initResult = E_FAIL; + DWORD m_threadId{ GetCurrentThreadId() }; }; Q_CORE_EXPORT bool qt_win_hasPackageIdentity(); |