From 14235ada48d5f3015571102549d56c8cfbcdcccb Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 9 Jul 2015 21:40:58 +0200 Subject: [PATCH] QGraphicsItem: don't hold ExtraStruct in a QList ExtraStruct is larger than a void*, so holding it in QList is needlessly inefficient. Worse, the code could come to depend on the fragile property of (inefficient) QLists that references to elements therein never are invalidated. Fix by marking it movable, and holding in a QVector instead. Change-Id: I02f2089859c2deccf0e6c451bf80da07893cc3f0 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/graphicsview/qgraphicsitem_p.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/widgets/graphicsview/qgraphicsitem_p.h b/src/widgets/graphicsview/qgraphicsitem_p.h index bf788d2c39..fe4bac12bc 100644 --- a/src/widgets/graphicsview/qgraphicsitem_p.h +++ b/src/widgets/graphicsview/qgraphicsitem_p.h @@ -353,6 +353,7 @@ public: } struct ExtraStruct { + ExtraStruct() {} // for QVector, don't use ExtraStruct(Extra type, QVariant value) : type(type), value(value) { } @@ -364,7 +365,7 @@ public: { return type < extra; } }; - QList extras; + QVector extras; QGraphicsItemCache *maybeExtraItemCache() const; QGraphicsItemCache *extraItemCache() const; @@ -584,6 +585,7 @@ public: int globalStackingOrder; QGraphicsItem *q_ptr; }; +Q_DECLARE_TYPEINFO(QGraphicsItemPrivate::ExtraStruct, Q_MOVABLE_TYPE); struct QGraphicsItemPrivate::TransformData {