From a082b41d2cdb72099cd5f6b7636b34836880d150 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 19 Jun 2015 13:11:03 +0200 Subject: [PATCH] QTextEngine: don't hold ItemDecoration in QList ItemDecoration is larger than a void*, so holding it in QLists 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 the type movable and holding in QVector instead. Change-Id: I06d7a77529f7cff2ba503c5e8d6e5df0ad801a21 Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Konstantin Ritt --- src/gui/text/qtextengine_p.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 3590c6da078..d2b39f274c7 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -400,6 +400,7 @@ public: }; struct ItemDecoration { + ItemDecoration() {} // for QVector, don't use ItemDecoration(qreal x1, qreal x2, qreal y, const QPen &pen): x1(x1), x2(x2), y(y), pen(pen) {} @@ -409,7 +410,7 @@ public: QPen pen; }; - typedef QList ItemDecorationList; + typedef QVector ItemDecorationList; QTextEngine(); QTextEngine(const QString &str, const QFont &f); @@ -643,6 +644,7 @@ public: LayoutData _layoutData; void *_memory[MemSize]; }; +Q_DECLARE_TYPEINFO(QTextEngine::ItemDecoration, Q_MOVABLE_TYPE); struct QTextLineItemIterator {