From b433c4b5a761cf035ccb0bfc0982e1b80d1c07b8 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 29 Jan 2014 15:11:14 +0100 Subject: Remove static initialization of QObjects 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 --- src/qml/compiler/qv4isel_p.cpp | 3 ++- src/qml/compiler/qv4ssa.cpp | 3 ++- 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 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) { -- cgit v1.2.3