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) <ogoffart@woboq.com>
bb10
Marc Mutz 2015-07-09 21:40:58 +02:00
parent 827d1ed633
commit 14235ada48
1 changed files with 3 additions and 1 deletions

View File

@ -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<ExtraStruct> extras;
QVector<ExtraStruct> 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
{