summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Zander <t.zander@nokia.com>2009-11-16 11:16:47 +0100
committerThomas Zander <thomas.zander@trolltech.com>2009-11-16 13:02:13 +0100
commit7e1f19c3e3036f166a84dbaa916ec1da1cc818c6 (patch)
tree8b1a7128a7e0549c4c734a0748643c007ad04bf2
parentdbaea6fa5a90742d89691685baa44a1a34598f21 (diff)
downloadqt4-tools-7e1f19c3e3036f166a84dbaa916ec1da1cc818c6.tar.gz
Fix regression in emitting of QTextDocument::undoCommandAdded()
The test I wrote was not testing if calling undo/redo had any effect on emitting undoCommandAdded(), added these test cases and fixed the QTextDocumentPrivate::endEditBlock so we now again emit only when an undo command is added, not also on calling undo or redo. Reviewed-by: mae Reviewed-by: Samuel Rødal
-rw-r--r--src/gui/text/qtextdocument_p.cpp4
-rw-r--r--tests/auto/qtextdocument/tst_qtextdocument.cpp11
2 files changed, 14 insertions, 1 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 2ad65127ec..18e1ffc989 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -1114,9 +1114,11 @@ void QTextDocumentPrivate::endEditBlock()
return;
if (undoEnabled && undoState > 0) {
+ const bool wasBlocking = !undoStack[undoState - 1].block_end;
if (undoStack[undoState - 1].block_part) {
undoStack[undoState - 1].block_end = true;
- emit document()->undoCommandAdded();
+ if (wasBlocking)
+ emit document()->undoCommandAdded();
}
}
diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp
index 1d54409513..11e32b061f 100644
--- a/tests/auto/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp
@@ -2615,6 +2615,17 @@ void tst_QTextDocument::testUndoCommandAdded()
cf.setFontItalic(true);
cursor.mergeCharFormat(cf);
QCOMPARE(spy.count(), 1);
+
+ spy.clear();
+ doc->undo();
+ QCOMPARE(spy.count(), 0);
+ doc->undo();
+ QCOMPARE(spy.count(), 0);
+ spy.clear();
+ doc->redo();
+ QCOMPARE(spy.count(), 0);
+ doc->redo();
+ QCOMPARE(spy.count(), 0);
}
void tst_QTextDocument::testUndoBlocks()