From 42925652f146d8ca4f1de8fac025d8a3e4a39857 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Mon, 19 Aug 2024 14:22:06 +0200 Subject: [PATCH] Utils: Fix crash in tests without QCoreApplication Change-Id: Iefe451d75668a68ce86a5c4b80f738acd5d6e8e4 Reviewed-by: Christian Kandeler --- src/libs/utils/devicefileaccess.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/utils/devicefileaccess.cpp b/src/libs/utils/devicefileaccess.cpp index 55ffe8ac750..a316c58db01 100644 --- a/src/libs/utils/devicefileaccess.cpp +++ b/src/libs/utils/devicefileaccess.cpp @@ -408,7 +408,9 @@ class DesktopFilePathWatcher final : public FilePathWatcher public: 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); }