summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-10-06 10:26:23 +0200
committerUlf Hermann <ulf.hermann@qt.io>2021-10-07 12:54:10 +0200
commit5d174877234477a59eb29818d3cfb99fedc3e704 (patch)
tree6131169395c5c33f3633ee21b5c13dc28435620b /src/corelib/kernel/qobject.h
parent1453f048f535d98ea2454462875eed77a966bcde (diff)
Return a plain QMetaObject* from toDynamicMetaObject()
The only place where we use it, we swiftly cast it to QMetaObject* anyway. Generating an object with virtual methods, only to then cast to its non-virtual base type is dangerous. Also, if we are required to return a QAbstractDynamicMetaObject from a method of QDynamicMetaObjectData, we cannot implement QDynamicMetaObjectData without also implementing QAbstractDynamicMetaObject. This indirectly forces us to copy metaobjects around as we cannot wrap an existing metaobject into a QDynamicMetaObjectData subclass. Copying metaobjects around makes QMetaObject::inherits() unusable because inherits() assumes identity is determined by identity of the pointer. Change-Id: Icbe697efa6fd66649eef3c91260c95cda62e3c90 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qobject.h')
-rw-r--r--src/corelib/kernel/qobject.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index c94fb17755..e75cf3217e 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -111,6 +111,9 @@ public:
int postedEvents;
QDynamicMetaObjectData *metaObject;
QBindingStorage bindingStorage;
+
+ // ### Qt7: Make this return a const QMetaObject *. You should not mess with
+ // the metaobjects of existing objects.
QMetaObject *dynamicMetaObject() const;
#ifdef QT_DEBUG