summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2017-02-20 10:55:59 +0100
committerDavid Faure <david.faure@kdab.com>2017-02-23 18:11:55 +0000
commit90b48a70ffb64d97211150fa0849dc0fa0023b7d (patch)
tree1dc0532f52bf05799dba5d627a753777932f6cf2 /src
parent8e9582847506bf17755415fdddd92c242407851c (diff)
QTextFormatCollection: replace copy ctor and op= with clear()
operator=, which was only used for clearing, wasn't clearing the hash. This led to a mismatch between the vector and the hash (given that the hash points into the vector). Spotted by interrupting kmail in gdb, and it was in this code iterating over a 2000 entries hash (the first vector entries not matching the hash, this code keep appending new entries for the same formats). This fixes QTBUG-8862 again, the initial fix having been accidentally reverted in 467b15a. Change-Id: Ia34b3d002a0199e1930431a4bbdb2ec981ed4ffc Task-number: QTBUG-8862 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qtextdocument_p.cpp2
-rw-r--r--src/gui/text/qtextformat.cpp17
-rw-r--r--src/gui/text/qtextformat_p.h5
3 files changed, 9 insertions, 15 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 7107c7c26e..7341fa8e83 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -265,7 +265,7 @@ void QTextDocumentPrivate::clear()
unreachableCharacterCount = 0;
modifiedState = 0;
modified = false;
- formats = QTextFormatCollection();
+ formats.clear();
int len = fragments.length();
fragments.clear();
blocks.clear();
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 39fec032dc..36e0a77bd0 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -3371,22 +3371,15 @@ QTextTableCellFormat::QTextTableCellFormat(const QTextFormat &fmt)
// ------------------------------------------------------
-
-QTextFormatCollection::QTextFormatCollection(const QTextFormatCollection &rhs)
-{
- formats = rhs.formats;
- objFormats = rhs.objFormats;
-}
-
-QTextFormatCollection &QTextFormatCollection::operator=(const QTextFormatCollection &rhs)
+QTextFormatCollection::~QTextFormatCollection()
{
- formats = rhs.formats;
- objFormats = rhs.objFormats;
- return *this;
}
-QTextFormatCollection::~QTextFormatCollection()
+void QTextFormatCollection::clear()
{
+ formats.clear();
+ objFormats.clear();
+ hashes.clear();
}
int QTextFormatCollection::indexForFormat(const QTextFormat &format)
diff --git a/src/gui/text/qtextformat_p.h b/src/gui/text/qtextformat_p.h
index f05bfaff71..3557c17a97 100644
--- a/src/gui/text/qtextformat_p.h
+++ b/src/gui/text/qtextformat_p.h
@@ -63,8 +63,7 @@ public:
QTextFormatCollection() {}
~QTextFormatCollection();
- QTextFormatCollection(const QTextFormatCollection &rhs);
- QTextFormatCollection &operator=(const QTextFormatCollection &rhs);
+ void clear();
inline QTextFormat objectFormat(int objectIndex) const
{ return format(objectFormatIndex(objectIndex)); }
@@ -104,6 +103,8 @@ public:
private:
QFont defaultFnt;
+
+ Q_DISABLE_COPY(QTextFormatCollection)
};
QT_END_NAMESPACE