summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qloggingregistry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qloggingregistry.cpp')
-rw-r--r--src/corelib/io/qloggingregistry.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp
index b5f8e30b80..cd97268d71 100644
--- a/src/corelib/io/qloggingregistry.cpp
+++ b/src/corelib/io/qloggingregistry.cpp
@@ -44,6 +44,7 @@
#include <QtCore/qstandardpaths.h>
#include <QtCore/qtextstream.h>
#include <QtCore/qdir.h>
+#include <QtCore/qcoreapplication.h>
// We can't use the default macros because this would lead to recursion.
// Instead let's define our own one that unconditionally logs...
@@ -255,6 +256,15 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line)
QLoggingRegistry::QLoggingRegistry()
: categoryFilter(defaultCategoryFilter)
{
+#if defined(Q_OS_ANDROID)
+ // Unless QCoreApplication has been constructed we can't be sure that
+ // we are on Qt's main thread. If we did allow logging here, we would
+ // potentially set Qt's main thread to Android's thread 0, which would
+ // confuse Qt later when running main().
+ if (!qApp)
+ return;
+#endif
+
initializeRules(); // Init on first use
}