summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2009-06-08 10:43:13 (GMT)
committermae <qt-info@nokia.com>2009-06-08 10:45:19 (GMT)
commit11303c676166cda3aae33e7e97939e9d2942271f (patch)
treeaaa7614498e58e8eb567a87fbc1fbbbccb8cab29 /src/gui/text
parentfded22680a728ecba93feb87733785537c234b02 (diff)
downloadQt-11303c676166cda3aae33e7e97939e9d2942271f.zip
Qt-11303c676166cda3aae33e7e97939e9d2942271f.tar.gz
Qt-11303c676166cda3aae33e7e97939e9d2942271f.tar.bz2
Revert signal emission order in QTextDocument to 4.5 behaviour
This is covered by the autotest tst_QTextDocument::receiveCursorPositionChangedAfterContentsChange() Reviewed-by: con
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qtextdocument_p.cpp8
-rw-r--r--src/gui/text/qtextdocument_p.h6
2 files changed, 11 insertions, 3 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index e1da4be..7700c14 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -193,6 +193,8 @@ QTextDocumentPrivate::QTextDocumentPrivate()
undoEnabled = true;
inContentsChange = false;
+ inEdit = false;
+
defaultTextOption.setTabStop(80); // same as in qtextengine.cpp
defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
@@ -439,6 +441,7 @@ void QTextDocumentPrivate::insert(int pos, int strPos, int strLength, int format
Q_ASSERT(pos >= 0 && pos < fragments.length());
Q_ASSERT(formats.format(format).isCharFormat());
+ beginEdit();
insert_string(pos, strPos, strLength, format, QTextUndoCommand::MoveCursor);
if (undoEnabled) {
int b = blocks.findNode(pos);
@@ -564,6 +567,7 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O
if (pos == to)
return;
+ beginEdit();
const bool needsInsert = to != -1;
#if !defined(QT_NO_DEBUG)
@@ -1106,6 +1110,8 @@ void QTextDocumentPrivate::finishEdit()
if (editBlock)
return;
+ inEdit = false;
+
if (framesDirty)
scan_frames(docChangeFrom, docChangeOldLength, docChangeLength);
@@ -1175,7 +1181,7 @@ void QTextDocumentPrivate::adjustDocumentChangesAndCursors(int from, int addedOr
for (int i = 0; i < cursors.size(); ++i) {
QTextCursorPrivate *curs = cursors.at(i);
if (curs->adjustPosition(from, addedOrRemoved, op) == QTextCursorPrivate::CursorMoved) {
- if (editBlock) {
+ if (editBlock || inEdit) {
if (!changedCursors.contains(curs))
changedCursors.append(curs);
} else {
diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h
index d754ff0..e10e7ae 100644
--- a/src/gui/text/qtextdocument_p.h
+++ b/src/gui/text/qtextdocument_p.h
@@ -202,6 +202,7 @@ public:
inline void beginEditBlock() { editBlock++; }
void joinPreviousEditBlock();
void endEditBlock();
+ inline void beginEdit() { inEdit = true; }
void finishEdit();
inline bool isInEditBlock() const { return editBlock; }
void enableUndoRedo(bool enable);
@@ -335,8 +336,9 @@ public:
QCss::StyleSheet parsedDefaultStyleSheet;
#endif
int maximumBlockCount;
- bool needsEnsureMaximumBlockCount;
- bool inContentsChange;
+ uint needsEnsureMaximumBlockCount : 1;
+ uint inContentsChange : 1;
+ uint inEdit : 1; // between beginEdit() and finishEdit()
QSizeF pageSize;
QString title;
QString url;