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>bb10
parent
974d791f36
commit
751ca5e5bd
|
|
@ -28,6 +28,7 @@ QComHelper::QComHelper(COINIT concurrencyModel)
|
|||
|
||||
QComHelper::~QComHelper()
|
||||
{
|
||||
Q_ASSERT(m_threadId == GetCurrentThreadId());
|
||||
if (SUCCEEDED(m_initResult))
|
||||
CoUninitialize();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ public:
|
|||
|
||||
private:
|
||||
HRESULT m_initResult = E_FAIL;
|
||||
DWORD m_threadId{ GetCurrentThreadId() };
|
||||
};
|
||||
|
||||
Q_CORE_EXPORT bool qt_win_hasPackageIdentity();
|
||||
|
|
|
|||
Loading…
Reference in New Issue