From 2a944f0b26c6f9732da8981962034aa0f2b9ecf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Wed, 6 Jul 2016 12:29:25 +0100 Subject: [PATCH] Resolves: rhbz#1352881 turn off undo generation during undo Change-Id: I6aa4ceb09b252ad0b04d8e0a89d8c3327f565b49 Reviewed-on: https://gerrit.libreoffice.org/26980 Tested-by: Jenkins Reviewed-by: Eike Rathke Tested-by: Eike Rathke (cherry picked from commit 06287b9c348281612854d67c4eb2e7a38dc722ca) Reviewed-on: https://gerrit.libreoffice.org/27065 --- sc/source/ui/undo/undobase.cxx | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx index 792cde5..0133f9a 100644 --- a/sc/source/ui/undo/undobase.cxx +++ b/sc/source/ui/undo/undobase.cxx @@ -96,9 +96,36 @@ void ScSimpleUndo::BeginUndo() pDetectiveUndo->Undo(); } +namespace +{ + class DisableUndoGuard + { + private: + ScDocument& m_rDoc; + bool m_bUndoEnabled; + public: + DisableUndoGuard(ScDocShell *pDocShell) + : m_rDoc(pDocShell->GetDocument()) + , m_bUndoEnabled(m_rDoc.IsUndoEnabled()) + { + m_rDoc.EnableUndo(false); + } + + ~DisableUndoGuard() + { + m_rDoc.EnableUndo(m_bUndoEnabled); + } + }; +} + void ScSimpleUndo::EndUndo() { - pDocShell->SetDocumentModified(); + { + // rhbz#1352881 Temporarily turn off undo generation during + // SetDocumentModified + DisableUndoGuard aGuard(pDocShell); + pDocShell->SetDocumentModified(); + } ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) @@ -125,7 +152,12 @@ void ScSimpleUndo::EndRedo() if (pDetectiveUndo) pDetectiveUndo->Redo(); - pDocShell->SetDocumentModified(); + { + // rhbz#1352881 Temporarily turn off undo generation during + // SetDocumentModified + DisableUndoGuard aGuard(pDocShell); + pDocShell->SetDocumentModified(); + } ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) -- 2.7.4