Utils: Fix crash in tests without QCoreApplication

Change-Id: Iefe451d75668a68ce86a5c4b80f738acd5d6e8e4
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Marcus Tillmanns
2024-08-19 14:22:06 +02:00
parent f170552244
commit 42925652f1

View File

@@ -408,7 +408,9 @@ class DesktopFilePathWatcher final : public FilePathWatcher
public: public:
GlobalWatcher() GlobalWatcher()
{ {
QTC_CHECK(QThread::currentThread() == qApp->thread()); // Normally we want to make sure that this object is created on the main thread.
// Certain tests might not have a qApp though, so we allow for that.
QTC_CHECK(!qApp || QThread::currentThread() == qApp->thread());
d.writeLocked()->init(this); d.writeLocked()->init(this);
} }