From 133e40283155852585b5fc409909a00e920cfcfc Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 1 Jun 2015 00:22:35 +0200 Subject: De-duplicate vtables, part I: exported private classes By making the destructor (usually the first non-inline, non-pure, virtual function, and therefore the trigger for most compilers to emit the vtable and type_info structures for the class in that TU) out-of-line, vtables and, more importantly, type_info structures for the class are pinned to a single TU. This prevents false negative dynamic_cast and catch evaluation. In this first batch, we de-inline destructors of exported private classes. Since they are already exported, users of these classes are unaffected by the change, and since it's private API, we don't need to avoid adding code to the out-of-line destructor until Qt 6. Change-Id: I450707877d2cb6a77f79ae1dd355facb98d6c517 Reported-by: Volker Krause Task-number: QTBUG-45582 Reviewed-by: Oswald Buddenhagen Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll Reviewed-by: Konstantin Ritt Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobject_p.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib/kernel/qobject_p.h') diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 1b64103e40..bd5ee006bf 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -406,7 +406,7 @@ void Q_CORE_EXPORT qDeleteInEventHandler(QObject *o); struct QAbstractDynamicMetaObject; struct Q_CORE_EXPORT QDynamicMetaObjectData { - virtual ~QDynamicMetaObjectData() {} + virtual ~QDynamicMetaObjectData(); virtual void objectDestroyed(QObject *) { delete this; } virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) = 0; @@ -415,6 +415,8 @@ struct Q_CORE_EXPORT QDynamicMetaObjectData struct Q_CORE_EXPORT QAbstractDynamicMetaObject : public QDynamicMetaObjectData, public QMetaObject { + ~QAbstractDynamicMetaObject(); + virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) Q_DECL_OVERRIDE { return this; } virtual int createProperty(const char *, const char *) { return -1; } virtual int metaCall(QObject *, QMetaObject::Call c, int _id, void **a) Q_DECL_OVERRIDE -- cgit v1.2.3