summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2021-04-14 22:30:06 +0800
committerAndras Timar <andras.timar@collabora.com>2021-04-21 21:07:36 +0200
commit04e9aa029c573d3707ebe76da66f4848b3a8caa7 (patch)
tree1a849552dbeb676b1242aeaefde32dfba0d04569 /svx
parent5802d15f993b219528fb304932c94b2f2f6fd9c4 (diff)
tdf#131634 Don't redo actions created before text edit begins.
In SdrObjEditView::SdrEndTextEdit(), pSdrUndoManager->Redo() was invoked until all the redo actions created after text edit began were converted to undo actions. Without checking, all the redo actions include the ones created before text edit began were moved to undo stack, and caused the SdrTextObj to be destroyed in SdrUndoManager::SetEndTextEditHdl when removing the undo actions and a use after release problem. The patch add GetRedoActionCountBeforeTextEdit() so the program won't invoke pSdrUndoManager->Redo() on actions created before text edit begin. Change-Id: Ic010bc6e71ee78ef2cb20a5259dc9d6d6579ccaa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114102 Tested-by: Jenkins Reviewed-by: Mark Hung <marklh9@gmail.com> (cherry picked from commit 7a641c71f8191e83bb6c408d3ff51a58d7dd4af9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114360 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/sdrundomanager.cxx3
-rw-r--r--svx/source/svdraw/svdedxv.cxx3
2 files changed, 5 insertions, 1 deletions
diff --git a/svx/source/svdraw/sdrundomanager.cxx b/svx/source/svdraw/sdrundomanager.cxx
index 1e64a1a89482..8b1f19fbecfa 100644
--- a/svx/source/svdraw/sdrundomanager.cxx
+++ b/svx/source/svdraw/sdrundomanager.cxx
@@ -25,6 +25,7 @@ SdrUndoManager::SdrUndoManager()
: EditUndoManager(20 /*nMaxUndoActionCount*/)
, maEndTextEditHdl()
, mpLastUndoActionBeforeTextEdit(nullptr)
+ , mnRedoActionCountBeforeTextEdit(0)
, mbEndTextEditTriggeredFromUndo(false)
, m_pDocSh(nullptr)
{
@@ -107,6 +108,7 @@ void SdrUndoManager::SetEndTextEditHdl(const Link<SdrUndoManager*, void>& rLink)
{
// text edit start, remember last non-textedit action for later cleanup
mpLastUndoActionBeforeTextEdit = GetUndoActionCount() ? GetUndoAction() : nullptr;
+ mnRedoActionCountBeforeTextEdit = GetRedoActionCount();
}
else
{
@@ -123,6 +125,7 @@ void SdrUndoManager::SetEndTextEditHdl(const Link<SdrUndoManager*, void>& rLink)
// forget marker again
mpLastUndoActionBeforeTextEdit = nullptr;
+ mnRedoActionCountBeforeTextEdit = 0;
}
}
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 0957eb9519b4..0dc6aad1fa3b 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -1438,7 +1438,8 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
// to create a complete text change undo action for the redo buffer. Also mark this
// state when at least one redo was executed; the created extra TextChange needs to
// be undone in addition to the first real undo outside the text edit changes
- while (pSdrUndoManager->GetRedoActionCount())
+ while (pSdrUndoManager->GetRedoActionCount()
+ > pSdrUndoManager->GetRedoActionCountBeforeTextEdit())
{
bNeedToUndoSavedRedoTextEdit = true;
pSdrUndoManager->Redo();