summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/global/qglobal.h6
-rw-r--r--src/tools/moc/generator.cpp4
2 files changed, 8 insertions, 2 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 4e7c1b59be..2464db7c5f 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -508,6 +508,12 @@ using qsizetype = QIntegerForSizeof<std::size_t>::Signed;
# define Q_ALWAYS_INLINE inline
#endif
+#ifdef Q_CC_GNU
+# define QT_INIT_METAOBJECT __attribute__((init_priority(101)))
+#else
+# define QT_INIT_METAOBJECT
+#endif
+
//defines the type for the WNDPROC on windows
//the alignment needs to be forced for sse2 to not crash with mingw
#if defined(Q_OS_WIN)
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index 139f7328af..1e17e00050 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -523,9 +523,9 @@ void Generator::generateCode()
// Finally create and initialize the static meta object
//
if (isQt)
- fprintf(out, "const QMetaObject QObject::staticQtMetaObject = {\n");
+ fprintf(out, "QT_INIT_METAOBJECT const QMetaObject QObject::staticQtMetaObject = {\n");
else
- fprintf(out, "const QMetaObject %s::staticMetaObject = {\n", cdef->qualified.constData());
+ fprintf(out, "QT_INIT_METAOBJECT const QMetaObject %s::staticMetaObject = {\n", cdef->qualified.constData());
if (isQObject)
fprintf(out, " { nullptr, ");