diff options
| author | Thomas Zander <t.zander@nokia.com> | 2009-11-16 10:16:47 (GMT) |
|---|---|---|
| committer | Jason McDonald <jason.mcdonald@nokia.com> | 2009-11-18 07:34:15 (GMT) |
| commit | 518f32a70d3e9eb869d4a19c6fef50b91475a60a (patch) | |
| tree | 4873728b02f880057b250b1655415521dceadee3 | |
| parent | 767518eff63a13038a805f5fc403ec98f0635433 (diff) | |
| download | Qt-518f32a70d3e9eb869d4a19c6fef50b91475a60a.zip Qt-518f32a70d3e9eb869d4a19c6fef50b91475a60a.tar.gz Qt-518f32a70d3e9eb869d4a19c6fef50b91475a60a.tar.bz2 | |
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
(cherry picked from commit 7e1f19c3e3036f166a84dbaa916ec1da1cc818c6)
| -rw-r--r-- | src/gui/text/qtextdocument_p.cpp | 4 | ||||
| -rw-r--r-- | tests/auto/qtextdocument/tst_qtextdocument.cpp | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index 2ad6512..18e1ffc 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 1d54409..11e32b0 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() |
