diff options
author | Harald Fernengel <harald@trolltech.com> | 2009-08-03 13:12:46 (GMT) |
---|---|---|
committer | Harald Fernengel <harald@trolltech.com> | 2009-08-03 13:12:46 (GMT) |
commit | 41a83e1ff19ad1396e6001e6b0ac003c701ba55a (patch) | |
tree | 609e40eda10418bbf925002c36552074796b96b6 /src/gui/text/qtextdocument_p.cpp | |
parent | d1f3b9df2bc5c57d414da73a7d4f9ed7b25df3db (diff) | |
download | Qt-41a83e1ff19ad1396e6001e6b0ac003c701ba55a.zip Qt-41a83e1ff19ad1396e6001e6b0ac003c701ba55a.tar.gz Qt-41a83e1ff19ad1396e6001e6b0ac003c701ba55a.tar.bz2 |
Squashed commit of the topic/exceptions branch.
Contains some smaller fixes and renaming of macros. Looks big,
but isn't scary at all ;)
Diffstat (limited to 'src/gui/text/qtextdocument_p.cpp')
-rw-r--r-- | src/gui/text/qtextdocument_p.cpp | 76 |
1 files changed, 41 insertions, 35 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index ea37e04..71baa88 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() |