From a07d9f21929933c440453fdbee337653611faa5d Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sun, 9 Jan 2011 17:55:16 +0000 Subject: [PATCH] Clear undo/redo stack when reloading buffer. This fixes #7208. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37155 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 1 + src/Undo.cpp | 10 ++++++++++ src/Undo.h | 3 +++ 3 files changed, 14 insertions(+) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 15314366a7..d58ee11cf3 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -4250,6 +4250,7 @@ Buffer::ReadStatus Buffer::reload() updateTitles(); markClean(); message(bformat(_("Document %1$s reloaded."), disp_fn)); + d->undo_.clear(); } else { message(bformat(_("Could not reload document %1$s."), disp_fn)); } diff --git a/src/Undo.cpp b/src/Undo.cpp index f41716647b..1c0bf64568 100644 --- a/src/Undo.cpp +++ b/src/Undo.cpp @@ -241,6 +241,16 @@ Undo::~Undo() } +void Undo::clear() +{ + d->undostack_.clear(); + d->redostack_.clear(); + d->undo_finished_ = true; + d->group_id = 0; + d->group_level; +} + + bool Undo::hasUndoStack() const { return !d->undostack_.empty(); diff --git a/src/Undo.h b/src/Undo.h index f91b02fe8f..5f6694104a 100644 --- a/src/Undo.h +++ b/src/Undo.h @@ -53,6 +53,9 @@ public: ~Undo(); + /// Clear out all undo/redo contents. + void clear(); + /// this will undo the last action - returns false if no undo possible bool textUndo(DocIterator &); -- 2.39.2