summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocument_p.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-06-13 09:01:02 +0200
committerLiang Qi <liang.qi@qt.io>2016-06-13 12:46:46 +0200
commit511790fd1af1e2886a0e2e8dd4308099705cd815 (patch)
treeb42aee537a6103cd064f9f41ae2889b09b79fd23 /src/gui/text/qtextdocument_p.cpp
parent1542d8881fc5ccbc5918cd4acbe4091ebbd24508 (diff)
parentcbe332405aa22257d432f1797b325f5e57007c20 (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: config_help.txt configure mkspecs/features/uikit/sdk.prf src/corelib/global/qhooks.cpp src/corelib/io/qfilesystemwatcher.cpp src/corelib/io/qlockfile_unix.cpp src/corelib/tools/qalgorithms.h src/gui/kernel/qwindowsysteminterface.h src/gui/text/qtextdocument_p.cpp src/network/access/access.pri src/network/access/qnetworkaccessmanager.cpp src/network/access/qnetworkreplynsurlconnectionimpl.mm src/src.pro src/testlib/qtestcase.cpp src/widgets/kernel/qwidgetbackingstore_p.h src/widgets/styles/qwindowscestyle.cpp src/widgets/styles/qwindowsmobilestyle.cpp tests/auto/corelib/io/qdiriterator/qdiriterator.pro tests/auto/corelib/io/qfileinfo/qfileinfo.pro tests/auto/gui/kernel/qwindow/BLACKLIST tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp tools/configure/configureapp.cpp Change-Id: Ibf7fb9c8cf263a810ade82f821345d0725c57c67
Diffstat (limited to 'src/gui/text/qtextdocument_p.cpp')
-rw-r--r--src/gui/text/qtextdocument_p.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index df0d52d8e9..3537adba9e 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -1006,9 +1006,9 @@ int QTextDocumentPrivate::undoRedo(bool undo)
bool inBlock = (
undoState > 0
&& undoState < undoStack.size()
- && undoStack[undoState].block_part
- && undoStack[undoState-1].block_part
- && !undoStack[undoState-1].block_end
+ && undoStack.at(undoState).block_part
+ && undoStack.at(undoState - 1).block_part
+ && !undoStack.at(undoState - 1).block_end
);
if (!inBlock)
break;
@@ -1074,13 +1074,14 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c)
if (!undoStack.isEmpty() && modified) {
- QTextUndoCommand &last = undoStack[undoState - 1];
+ const int lastIdx = undoState - 1;
+ const QTextUndoCommand &last = undoStack.at(lastIdx);
if ( (last.block_part && c.block_part && !last.block_end) // part of the same block => can merge
|| (!c.block_part && !last.block_part) // two single undo items => can merge
|| (c.command == QTextUndoCommand::Inserted && last.command == c.command && (last.block_part && !c.block_part))) {
// two sequential inserts that are not part of the same block => can merge
- if (last.tryMerge(c))
+ if (undoStack[lastIdx].tryMerge(c))
return;
}
}
@@ -1102,7 +1103,7 @@ void QTextDocumentPrivate::clearUndoRedoStacks(QTextDocument::Stacks stacksToCle
bool redoCommandsAvailable = undoState != undoStack.size();
if (stacksToClear == QTextDocument::UndoStack && undoCommandsAvailable) {
for (int i = 0; i < undoState; ++i) {
- QTextUndoCommand c = undoStack[undoState];
+ QTextUndoCommand c = undoStack.at(undoState);
if (c.command & QTextUndoCommand::Custom)
delete c.custom;
}
@@ -1114,7 +1115,7 @@ void QTextDocumentPrivate::clearUndoRedoStacks(QTextDocument::Stacks stacksToCle
} else if (stacksToClear == QTextDocument::RedoStack
&& redoCommandsAvailable) {
for (int i = undoState; i < undoStack.size(); ++i) {
- QTextUndoCommand c = undoStack[i];
+ QTextUndoCommand c = undoStack.at(i);
if (c.command & QTextUndoCommand::Custom)
delete c.custom;
}
@@ -1124,7 +1125,7 @@ void QTextDocumentPrivate::clearUndoRedoStacks(QTextDocument::Stacks stacksToCle
} else if (stacksToClear == QTextDocument::UndoAndRedoStacks
&& !undoStack.isEmpty()) {
for (int i = 0; i < undoStack.size(); ++i) {
- QTextUndoCommand c = undoStack[i];
+ QTextUndoCommand c = undoStack.at(i);
if (c.command & QTextUndoCommand::Custom)
delete c.custom;
}
@@ -1187,8 +1188,8 @@ void QTextDocumentPrivate::endEditBlock()
return;
if (undoEnabled && undoState > 0) {
- const bool wasBlocking = !undoStack[undoState - 1].block_end;
- if (undoStack[undoState - 1].block_part) {
+ const bool wasBlocking = !undoStack.at(undoState - 1).block_end;
+ if (undoStack.at(undoState - 1).block_part) {
undoStack[undoState - 1].block_end = true;
if (wasBlocking)
emit document()->undoCommandAdded();