summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBenjamin Poulain <benjamin.poulain@nokia.com>2009-03-26 12:40:18 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-03-26 12:40:52 (GMT)
commit2ba3cd8175e54a2e122591f12dacdeaa81a9af46 (patch)
treee4d714166eb2d016be65914b8d0d2c79a559ef9a /tests
parentb641daa11d579f58468be7f30042a100d8c483c5 (diff)
downloadQt-2ba3cd8175e54a2e122591f12dacdeaa81a9af46.zip
Qt-2ba3cd8175e54a2e122591f12dacdeaa81a9af46.tar.gz
Qt-2ba3cd8175e54a2e122591f12dacdeaa81a9af46.tar.bz2
Fix crash when accessing newly constructed QTextObjects.
The pieceTable member was only initialized by QTextDocumentPrivate _after_ the call to createObject. This patch initializes it at construction time. Task-number: 246138 Reviewed-by: Simon Hausmann
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtextobject/tst_qtextobject.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/qtextobject/tst_qtextobject.cpp b/tests/auto/qtextobject/tst_qtextobject.cpp
index 4fbc155..4d1d4b2 100644
--- a/tests/auto/qtextobject/tst_qtextobject.cpp
+++ b/tests/auto/qtextobject/tst_qtextobject.cpp
@@ -62,6 +62,7 @@ public:
private slots:
void getSetCheck();
+ void testStandAloneTextObject();
};
tst_QTextObject::tst_QTextObject()
@@ -105,5 +106,23 @@ void tst_QTextObject::getSetCheck()
QCOMPARE(INT_MAX, obj2.userState());
}
+class TestTextObject : public QTextObject
+{
+public:
+ TestTextObject(QTextDocument *document) : QTextObject(document) {}
+};
+
+void tst_QTextObject::testStandAloneTextObject()
+{
+ QTextDocument document;
+ TestTextObject textObject(&document);
+
+ QCOMPARE(textObject.document(), &document);
+ // don't crash
+ textObject.format();
+ textObject.formatIndex();
+ QCOMPARE(textObject.objectIndex(), -1);
+}
+
QTEST_MAIN(tst_QTextObject)
#include "tst_qtextobject.moc"