summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobjectdefs.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-06-21 11:08:58 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-06-28 15:07:41 -0700
commit688e8f63a2bb87469517166f90c50dec524f90c5 (patch)
tree8678a48dc4deb6c31c1d80a23c09daf2794e8743 /src/corelib/kernel/qobjectdefs.h
parent9af59838d7ba166966941199354f905b0a122cab (diff)
moc: fix const-init for Windows
References to __declspec(dllimport) is not a constant expression on Windows, so we can't have a direct reference to a staticMetaObject. Commit 9b8493314dd77f3e96b353187816bb7ef4dedbb5 fixed the Q_OBJECT parent link (added in 5.14, kicked in for 6.0 with the ABI break), but commit 656d6f2a9b221dbd5adfc46262cb243e696d8d62 added links for Q_GADGETs too without taking the need for Windows DLLs into account. This change is a no-op everywhere but Windows. On Windows, since we store the pointer to the indirect getter function, now you may get non- null pointers from QMetaObject::superClass(). Pick-to: 6.4 Change-Id: I6d3880c7d99d4fc494c8fffd16fab51aa255106e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qobjectdefs.h')
-rw-r--r--src/corelib/kernel/qobjectdefs.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 0fca56f703..8309e43d89 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -369,6 +369,7 @@ struct Q_CORE_EXPORT QMetaObject
}
struct SuperData {
+ using Getter = const QMetaObject *(*)();
const QMetaObject *direct;
SuperData() = default;
constexpr SuperData(std::nullptr_t) : direct(nullptr) {}
@@ -377,7 +378,6 @@ struct Q_CORE_EXPORT QMetaObject
constexpr const QMetaObject *operator->() const { return operator const QMetaObject *(); }
#ifdef QT_NO_DATA_RELOCATION
- using Getter = const QMetaObject *(*)();
Getter indirect = nullptr;
constexpr SuperData(Getter g) : direct(nullptr), indirect(g) {}
constexpr operator const QMetaObject *() const
@@ -385,6 +385,7 @@ struct Q_CORE_EXPORT QMetaObject
template <const QMetaObject &MO> static constexpr SuperData link()
{ return SuperData(QMetaObject::staticMetaObject<MO>); }
#else
+ constexpr SuperData(Getter g) : direct(g()) {}
constexpr operator const QMetaObject *() const
{ return direct; }
template <const QMetaObject &MO> static constexpr SuperData link()