From 5c0cf4cc51b8ba40fcd32bfd854d94e36ae117ff Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 3 Mar 2014 18:24:51 +0100 Subject: [PATCH] Fix bug #8998: changed document setting is recoded twice as undo The general trick to avoid this kind of problems is to use undo groups. --- src/frontends/qt4/GuiDocument.cpp | 10 ++++++++++ status.20x | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index a678755f8d..b5856614d6 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -47,6 +47,7 @@ #include "qt_helpers.h" #include "Spacing.h" #include "TextClass.h" +#include "Undo.h" #include "insets/InsetListingsParams.h" @@ -3328,6 +3329,11 @@ static void dispatch_bufferparams(Dialog const & dialog, void GuiDocument::dispatchParams() { + // We need a non-const buffer object. + Buffer & buf = const_cast(bufferview())->buffer(); + // There may be several undo records; group them (bug #8998) + buf.undo().beginUndoGroup(); + // This must come first so that a language change is correctly noticed setLanguage(); @@ -3397,6 +3403,10 @@ void GuiDocument::dispatchParams() // If we used an LFUN, we would not need these two lines: BufferView * bv = const_cast(bufferview()); bv->processUpdateFlags(Update::Force | Update::FitCursor); + + // Don't forget to close the group. Note that it is important + // to check that there is no early return in the method. + buf.undo().endUndoGroup(); } diff --git a/status.20x b/status.20x index 476434cff2..66f5198223 100644 --- a/status.20x +++ b/status.20x @@ -95,6 +95,8 @@ What's new - Handle undo in `branch-add' function. +- Avoid multiple undo steps when changing document settings (bug 8998). + - Prevent recurrent pop-up of "missing module requirements" warning (bug 8864). - Do not close shortcut box if we receive bad input (bug 8703).