Windows: Add helper function to initialize COM per thread
This adapts a pattern first introduced for qtmultimedia (7398c5daa9). Pick-to: 6.9 6.9.0 Change-Id: I4682fcf49fe074c55b4a70a1e1ec659b33b31bbb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
f673d38129
commit
f5ac4a7f14
@ -33,6 +33,23 @@ QComHelper::~QComHelper()
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Make sure the COM library is is initialized on current thread.
|
||||
|
||||
Initializes COM as a single-threaded apartment on this thread and
|
||||
ensures that CoUninitialize will be called on the same thread when
|
||||
the thread exits. Note that the last call to CoUninitialize on the
|
||||
main thread will always be made during destruction of static
|
||||
variables at process exit.
|
||||
|
||||
https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/modernize-packaged-apps
|
||||
*/
|
||||
void qt_win_ensureComInitializedOnThisThread()
|
||||
{
|
||||
static thread_local QComHelper s_comHelper;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Checks if the application has a \e{package identity}
|
||||
|
@ -42,6 +42,8 @@ private:
|
||||
DWORD m_threadId{ GetCurrentThreadId() };
|
||||
};
|
||||
|
||||
Q_CORE_EXPORT void qt_win_ensureComInitializedOnThisThread();
|
||||
|
||||
Q_CORE_EXPORT bool qt_win_hasPackageIdentity();
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
x
Reference in New Issue
Block a user