qt5base-lts/src/corelib/global
Martin Storsjö 74118a4784 moc: Initialize staticMetaObject with the highest user-settable priority
The referenced static meta object for the superclass might be in a
different DLL. In this case, the whole QMetaObject can't be initialized
all via preinitialized data in the data section of the binary, but must
run code at runtime to fill in the value of the dllimported pointer.

In these cases, both GCC and MSVC initialize as much as possible statically,
while only filling in the dllimported values (QMetaObject::d::superdata)
at runtime. Clang, on the other side, initializes the whole struct
at runtime if some part of it needs runtime initialization, leaving
the struct completely uninitialized before constructors are run.

In C++, there are no guarantees for in what order constructors in
different translation units are executed. This in particular means
that there are no guarantees as to whether qRegisterWidgetsVariant()
in qwidgetsvariants.cpp runs before or after the runtime initialization
of QWidget::staticMetaObject.

With GCC and MSVC, this doesn't seem to have mattered since only the
superdata pointer of the staticMetaObject was uninitialized - everything
else was initialized, and the superdata pointer doesn't seem to be
accessed during qRegisterWidgetsVariant.

With clang, the whole staticMetaObject is uninitialized, unless the
staticMetaObject has been initialized before (and the initialization
order is undefined).

By setting a manual priority (which is a GCC extension that also
clang supports) for the staticMetaObjects, we can be sure that
these are initialized before the actual explicit constructor
invocations (without any explicit initialization priority) that
can access the staticMetaObjects.

Change-Id: I64a82f12d690528567509791bae088b6304e189b
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2018-01-09 18:36:46 +00:00
..
archdetect.cpp Add "-softfloat" to archdetect.cpp and clarify what to use when 2016-06-19 18:46:36 +00:00
global.pri Merge remote-tracking branch 'origin/5.9' into 5.10 2017-12-30 12:09:53 +01:00
minimum-linux_p.h QTemporaryFile: hide the O_TMPFILE feature behind a check for linkat() 2017-11-11 08:12:11 +00:00
minimum-linux.S Move the minimum Linux version declarations to a header 2017-10-28 06:08:59 +00:00
qcompilerdetection.h Change fallthrough detection order to fix clang detection 2017-11-07 19:37:06 +00:00
qconfig-bootstrapped.h QTemporaryFile: hide the O_TMPFILE feature behind a check for linkat() 2017-11-11 08:12:11 +00:00
qendian_p.h Move endian-specific integer types to public qtendian header 2017-07-09 09:00:16 +00:00
qendian.h Move endian-specific integer types to public qtendian header 2017-07-09 09:00:16 +00:00
qendian.qdoc Move endian-specific integer types to public qtendian header 2017-07-09 09:00:16 +00:00
qflags.h QFlags: support enum classes in setFlag() 2017-11-24 18:23:34 +00:00
qfloat16_p.h qfloat16: NaN is not infinite 2017-12-27 11:50:09 +00:00
qfloat16.cpp improve docs for qfloat16 2017-05-17 11:52:58 +00:00
qfloat16.h Merge remote-tracking branch 'origin/5.9' into 5.10 2017-11-23 12:52:18 +01:00
qglobal_p.h Add a "shim" to allow use of Clang 5's __builtin_available everywhere 2017-12-08 19:23:04 +00:00
qglobal.cpp Merge remote-tracking branch 'origin/5.9' into 5.10 2017-12-30 12:09:53 +01:00
qglobal.h moc: Initialize staticMetaObject with the highest user-settable priority 2018-01-09 18:36:46 +00:00
qglobalstatic.h Merge remote-tracking branch 'origin/5.6' into 5.7 2016-05-06 15:36:44 +02:00
qglobalstatic.qdoc rename qglobalstatic.cpp -> qglobalstatic.qdoc 2017-06-17 06:48:10 +00:00
qhooks_p.h Make sure all private headers in Qt Core include qglobal_p.h 2016-06-25 08:01:04 +00:00
qhooks.cpp QHostAddress: make it implictly shared 2017-01-19 14:09:47 +00:00
qisenum.h Remove compiler-specific implementations of Q_IS_ENUM 2016-11-09 09:13:01 +00:00
qlibraryinfo.cpp Fix warnings for -no-feature-settings 2017-04-04 13:12:19 +00:00
qlibraryinfo.h revert to building qmake with qconfig.cpp 2017-01-06 20:09:08 +00:00
qlogging.cpp Merge remote-tracking branch 'origin/5.9' into 5.10 2017-12-30 12:09:53 +01:00
qlogging.h Updated license headers 2016-01-15 12:25:24 +00:00
qmalloc.cpp Fix qReallocAligned for reallocation when alignment > 2*sizeof(void*) 2017-04-04 07:08:16 +00:00
qnamespace.h Merge remote-tracking branch 'origin/5.9' into 5.10 2017-12-30 12:09:53 +01:00
qnamespace.qdoc Unify wording in documentation to use 'top-left' instead 'upper-left' 2017-10-14 10:05:15 +00:00
qnumeric_p.h Mark some more functions with Q_DECL_CONST_FUNCTION 2017-04-05 08:00:04 +00:00
qnumeric.cpp Updated license headers 2016-01-15 12:25:24 +00:00
qnumeric.h Mark some more functions with Q_DECL_CONST_FUNCTION 2017-04-05 08:00:04 +00:00
qoperatingsystemversion_darwin.mm Remove compatibility code paths for macOS < 10.10 and iOS < 8.0 2017-01-09 10:11:48 +00:00
qoperatingsystemversion_p.h Add a "shim" to allow use of Clang 5's __builtin_available everywhere 2017-12-08 19:23:04 +00:00
qoperatingsystemversion_win_p.h Add a "shim" to allow use of Clang 5's __builtin_available everywhere 2017-12-08 19:23:04 +00:00
qoperatingsystemversion_win.cpp Add a "shim" to allow use of Clang 5's __builtin_available everywhere 2017-12-08 19:23:04 +00:00
qoperatingsystemversion.cpp Add currentType function to QOperatingSystemVersion 2017-09-25 00:58:41 +00:00
qoperatingsystemversion.h Add currentType function to QOperatingSystemVersion 2017-09-25 00:58:41 +00:00
qprocessordetection.h Add Integrity ARMv8 detection 2017-05-29 09:46:20 +00:00
qrandom_p.h Change QRandomGenerator to have a deterministic mode 2017-11-11 08:11:00 +00:00
qrandom.cpp Doc: attempt to fix some qdoc errors for QRandomGenerator 2017-12-24 02:04:10 +00:00
qrandom.h qrandom.h: actually #undef min and max instead of using parentheses 2017-12-28 21:30:28 +00:00
qsysinfo.h QSysInfo: Make use of the QT_WARNING_DISABLE_DEPRECATED macro 2017-04-27 15:27:25 +00:00
qsystemdetection.h Update OS version constants in qsystemdetection.h 2017-07-16 23:04:34 +00:00
qt_pch.h Updated license headers 2016-01-15 12:25:24 +00:00
qt_windows.h MinGW: Globally define WINVER and _WIN32_WINNT to enable Windows 7 API 2017-10-19 10:58:59 +00:00
qtypeinfo.h Merge remote-tracking branch 'origin/5.9' into dev 2017-02-28 13:03:36 +01:00
qtypetraits.h Remove qtypetraits.h's contents altogether 2017-01-12 22:16:06 +00:00
qversiontagging.cpp Updated license headers 2016-01-21 18:55:18 +00:00
qversiontagging.h Use the namespace-mangled symbol for the qt_version_tag group name 2017-07-07 07:22:03 +00:00