summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qobject.cpp10
-rw-r--r--src/corelib/kernel/qobject_p.h24
2 files changed, 25 insertions, 9 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index a51b794604..a8e2c43934 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -184,15 +184,7 @@ QMetaObject *QObjectData::dynamicMetaObject() const
QObjectPrivate::QObjectPrivate(int version)
: threadData(nullptr), currentChildBeingDeleted(nullptr)
{
-#ifdef QT_BUILD_INTERNAL
- // Don't check the version parameter in internal builds.
- // This allows incompatible versions to be loaded, possibly for testing.
- Q_UNUSED(version);
-#else
- if (Q_UNLIKELY(version != QObjectPrivateVersion))
- qFatal("Cannot mix incompatible Qt library (version 0x%x) with this library (version 0x%x)",
- version, QObjectPrivateVersion);
-#endif
+ checkForIncompatibleLibraryVersion(version);
// QObjectData initialization
q_ptr = nullptr;
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 838a9aa8c5..34b7447d5d 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -322,6 +322,8 @@ public:
virtual ~QObjectPrivate();
void deleteChildren();
+ inline void checkForIncompatibleLibraryVersion(int version) const;
+
void setParent_helper(QObject *);
void moveToThread_helper();
void setThreadData_helper(QThreadData *currentData, QThreadData *targetData);
@@ -396,6 +398,28 @@ public:
Q_DECLARE_TYPEINFO(QObjectPrivate::ConnectionList, Q_MOVABLE_TYPE);
+/*
+ Catch mixing of incompatible library versions.
+
+ Should be called from the constructor of every non-final subclass
+ of QObjectPrivate, to ensure we catch incompatibilities between
+ the intermediate base and subclasses thereof.
+*/
+inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) const
+{
+#if defined(QT_BUILD_INTERNAL)
+ // Don't check the version parameter in internal builds.
+ // This allows incompatible versions to be loaded, possibly for testing.
+ Q_UNUSED(version);
+#else
+ if (Q_UNLIKELY(version != QObjectPrivateVersion)) {
+ qFatal("Cannot mix incompatible Qt library (%d.%d.%d) with this library (%d.%d.%d)",
+ (version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff,
+ (QObjectPrivateVersion >> 16) & 0xff, (QObjectPrivateVersion >> 8) & 0xff, QObjectPrivateVersion & 0xff);
+ }
+#endif
+}
+
inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
{
return declarativeData && QAbstractDeclarativeData::isSignalConnected