74118a4784
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> |
||
---|---|---|
.. | ||
archdetect.cpp | ||
global.pri | ||
minimum-linux_p.h | ||
minimum-linux.S | ||
qcompilerdetection.h | ||
qconfig-bootstrapped.h | ||
qendian_p.h | ||
qendian.h | ||
qendian.qdoc | ||
qflags.h | ||
qfloat16_p.h | ||
qfloat16.cpp | ||
qfloat16.h | ||
qglobal_p.h | ||
qglobal.cpp | ||
qglobal.h | ||
qglobalstatic.h | ||
qglobalstatic.qdoc | ||
qhooks_p.h | ||
qhooks.cpp | ||
qisenum.h | ||
qlibraryinfo.cpp | ||
qlibraryinfo.h | ||
qlogging.cpp | ||
qlogging.h | ||
qmalloc.cpp | ||
qnamespace.h | ||
qnamespace.qdoc | ||
qnumeric_p.h | ||
qnumeric.cpp | ||
qnumeric.h | ||
qoperatingsystemversion_darwin.mm | ||
qoperatingsystemversion_p.h | ||
qoperatingsystemversion_win_p.h | ||
qoperatingsystemversion_win.cpp | ||
qoperatingsystemversion.cpp | ||
qoperatingsystemversion.h | ||
qprocessordetection.h | ||
qrandom_p.h | ||
qrandom.cpp | ||
qrandom.h | ||
qsysinfo.h | ||
qsystemdetection.h | ||
qt_pch.h | ||
qt_windows.h | ||
qtypeinfo.h | ||
qtypetraits.h | ||
qversiontagging.cpp | ||
qversiontagging.h |