From 29208fa07c1b9f656ea2535696828385b7832226 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 10 Sep 2018 12:19:09 +0200 Subject: winrt: Explicitly set main thread in QCoreApplication's constructor For winrt we cannot rely on the fact, that QThread::current will be called from the correct thread for the first time. The application's main entry point creates a suspended thread and starts it right afterwards. At that moment, other functionality (QLoggingRegistry for example) might have called QThread::current, which set the wrong thread as the main thread. In order to avoid this situation, the main thread is explicitly set in QCoreApplication's constructor. Task-number: QTBUG-66418 Change-Id: I8b6347357a80eb395ae758bd3d420adef0826751 Reviewed-by: Friedemann Kleint Reviewed-by: Simon Hausmann --- src/corelib/thread/qthread_p.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib/thread/qthread_p.h') diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 64e3f33191..7d9442ab79 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -243,6 +243,9 @@ public: ~QThreadData(); static Q_AUTOTEST_EXPORT QThreadData *current(bool createIfNecessary = true); +#ifdef Q_OS_WINRT + static void setMainThread(); +#endif static void clearCurrentThreadData(); static QThreadData *get2(QThread *thread) { Q_ASSERT_X(thread != 0, "QThread", "internal error"); return thread->d_func()->data; } -- cgit v1.2.3