De-duplicate QGraphicsItemPrivate vtable

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.

Since QGraphicsItemPrivate is already exported, users of this class
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.

Also saves ~2.5KiB in text size on optimized GCC 4.9 Linux AMD64
builds.

Task-number: QTBUG-45582
Change-Id: Ibb404a43d5464e8e280ccebd5f95719852f5a986
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Marc Mutz 2015-06-01 00:22:35 +02:00
parent d44cd5334a
commit 1cf2620d5b
2 changed files with 8 additions and 2 deletions

View File

@ -810,6 +810,13 @@ static QPainterPath qt_graphicsItem_shapeFromPath(const QPainterPath &path, cons
return p;
}
/*!
\internal
*/
QGraphicsItemPrivate::~QGraphicsItemPrivate()
{
}
/*!
\internal

View File

@ -237,8 +237,7 @@ public:
{
}
inline virtual ~QGraphicsItemPrivate()
{ }
virtual ~QGraphicsItemPrivate();
static const QGraphicsItemPrivate *get(const QGraphicsItem *item)
{