summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocument_p.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text/qtextdocument_p.cpp')
-rw-r--r--src/gui/text/qtextdocument_p.cpp76
1 files changed, 41 insertions, 35 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index ea37e044c0..71baa88b1b 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -179,6 +179,7 @@ QTextDocumentPrivate::QTextDocumentPrivate()
docChangeOldLength(0),
docChangeLength(0),
framesDirty(true),
+ rtFrame(0),
initialBlockCharFormatIndex(-1) // set correctly later in init()
{
editBlock = 0;
@@ -209,7 +210,6 @@ QTextDocumentPrivate::QTextDocumentPrivate()
void QTextDocumentPrivate::init()
{
- rtFrame = 0;
framesDirty = false;
bool undoState = undoEnabled;
@@ -232,42 +232,48 @@ void QTextDocumentPrivate::clear()
}
QList<QTextCursorPrivate *>oldCursors = cursors;
- cursors.clear();
- changedCursors.clear();
-
- QMap<int, QTextObject *>::Iterator objectIt = objects.begin();
- while (objectIt != objects.end()) {
- if (*objectIt != rtFrame) {
- delete *objectIt;
- objectIt = objects.erase(objectIt);
- } else {
- ++objectIt;
+ QT_TRY{
+ cursors.clear();
+ changedCursors.clear();
+
+ QMap<int, QTextObject *>::Iterator objectIt = objects.begin();
+ while (objectIt != objects.end()) {
+ if (*objectIt != rtFrame) {
+ delete *objectIt;
+ objectIt = objects.erase(objectIt);
+ } else {
+ ++objectIt;
+ }
}
- }
- // also clear out the remaining root frame pointer
- // (we're going to delete the object further down)
- objects.clear();
+ // also clear out the remaining root frame pointer
+ // (we're going to delete the object further down)
+ objects.clear();
- title.clear();
- undoState = 0;
- truncateUndoStack();
- text = QString();
- unreachableCharacterCount = 0;
- modifiedState = 0;
- modified = false;
- formats = QTextFormatCollection();
- int len = fragments.length();
- fragments.clear();
- blocks.clear();
- cachedResources.clear();
- delete rtFrame;
- init();
- cursors = oldCursors;
- inContentsChange = true;
- q->contentsChange(0, len, 0);
- inContentsChange = false;
- if (lout)
- lout->documentChanged(0, len, 0);
+ title.clear();
+ undoState = 0;
+ truncateUndoStack();
+ text = QString();
+ unreachableCharacterCount = 0;
+ modifiedState = 0;
+ modified = false;
+ formats = QTextFormatCollection();
+ int len = fragments.length();
+ fragments.clear();
+ blocks.clear();
+ cachedResources.clear();
+ delete rtFrame;
+ rtFrame = 0;
+ init();
+ cursors = oldCursors;
+ inContentsChange = true;
+ q->contentsChange(0, len, 0);
+ inContentsChange = false;
+ if (lout)
+ lout->documentChanged(0, len, 0);
+ } QT_CATCH(...) {
+ cursors = oldCursors; // at least recover the cursors
+ QT_RETHROW;
+ }
}
QTextDocumentPrivate::~QTextDocumentPrivate()