diff options
authorEskil Abrahamsen Blomfeldt <>2014-01-29 15:11:14 +0100
committerThe Qt Project <>2014-01-29 19:15:15 +0100
commitb433c4b5a761cf035ccb0bfc0982e1b80d1c07b8 (patch)
parente7cf8b10ff9e8d70f90c2f27df60f9e040be6911 (diff)
Remove static initialization of QObjectsv5.2.1
Statically initializing QObjects will cause e.g. the main thread pointer in QCoreApplication to be set when the library is loading. On Android, this is never the real main thread. The effect was a warning about QApplication not being initialized on main thread, and a race condition which sometimes caused apps to hang on startup. [ChangeLog][Android] Fixed possible hang on startup for Qt Quick applications. Task-number: QTBUG-36426 Change-Id: I7bd8a8f35ef1a2548949978563e3157f8dc854c7 Reviewed-by: Simon Hausmann <>
2 files changed, 4 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4isel_p.cpp b/src/qml/compiler/qv4isel_p.cpp
index b86837e167..644e06b59a 100644
--- a/src/qml/compiler/qv4isel_p.cpp
+++ b/src/qml/compiler/qv4isel_p.cpp
@@ -53,7 +53,8 @@
#include <cassert>
namespace {
-QTextStream qout(stderr, QIODevice::WriteOnly);
+Q_GLOBAL_STATIC_WITH_ARGS(QTextStream, qout, (stderr, QIODevice::WriteOnly));
+#define qout *qout()
} // anonymous namespace
using namespace QQmlJS;
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp
index 7113dc7c26..d0602bf95b 100644
--- a/src/qml/compiler/qv4ssa.cpp
+++ b/src/qml/compiler/qv4ssa.cpp
@@ -77,7 +77,8 @@ using namespace V4IR;
namespace {
-QTextStream qout(stdout, QIODevice::WriteOnly);
+Q_GLOBAL_STATIC_WITH_ARGS(QTextStream, qout, (stderr, QIODevice::WriteOnly));
+#define qout *qout()
void showMeTheCode(Function *function)