summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2021-04-14 22:30:06 +0800
committerMichael Stahl <michael.stahl@allotropia.de>2021-04-21 11:41:03 +0200
commit016a83306f6744892038b1bd9e6a6817e6a8c087 (patch)
tree81b3150cb7360da737c29b10b7677e21f4a5e9d8
parentd98f0bee1376b8002bbf5e3a96ab6e16ced1d880 (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>
-rw-r--r--include/svx/sdrundomanager.hxx2
-rw-r--r--svx/source/svdraw/sdrundomanager.cxx3
-rw-r--r--svx/source/svdraw/svdedxv.cxx3
3 files changed, 7 insertions, 1 deletions
diff --git a/include/svx/sdrundomanager.hxx b/include/svx/sdrundomanager.hxx
index 12fa1c7b3852..9ff23e441c54 100644
--- a/include/svx/sdrundomanager.hxx
+++ b/include/svx/sdrundomanager.hxx
@@ -33,6 +33,7 @@ private:
Link<SdrUndoManager*, void> maEndTextEditHdl;
SfxUndoAction* mpLastUndoActionBeforeTextEdit;
+ size_t mnRedoActionCountBeforeTextEdit;
bool mbEndTextEditTriggeredFromUndo;
SfxObjectShell* m_pDocSh;
@@ -64,6 +65,7 @@ public:
// by a last undo during text edit
bool isEndTextEditTriggeredFromUndo() const { return mbEndTextEditTriggeredFromUndo; }
void SetDocShell(SfxObjectShell* pDocShell);
+ size_t GetRedoActionCountBeforeTextEdit() const { return mnRedoActionCountBeforeTextEdit; }
};
#endif // INCLUDED_SVX_SDRUNDOMANAGER_HXX
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 8220b4c59b03..736d31b7aac5 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();