]> git.lyx.org Git - lyx.git/commitdiff
Fix bug #8998: changed document setting is recoded twice as undo
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 3 Mar 2014 17:24:51 +0000 (18:24 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 3 Mar 2014 17:28:23 +0000 (18:28 +0100)
The general trick to avoid this kind of problems is to use undo groups.

src/frontends/qt4/GuiDocument.cpp

index 1ac9259586779bc75e5722bd1b313b3692ea5b46..caa3d22d2e2c6d2fbf11393b2560250a5868e324 100644 (file)
@@ -50,6 +50,7 @@
 #include "qt_helpers.h"
 #include "Spacing.h"
 #include "TextClass.h"
+#include "Undo.h"
 
 #include "insets/InsetListingsParams.h"
 
@@ -3679,6 +3680,11 @@ static void dispatch_bufferparams(Dialog const & dialog,
 
 void GuiDocument::dispatchParams()
 {
+       // We need a non-const buffer object.
+       Buffer & buf = const_cast<BufferView *>(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();
 
@@ -3748,6 +3754,10 @@ void GuiDocument::dispatchParams()
        // If we used an LFUN, we would not need these two lines:
        BufferView * bv = const_cast<BufferView *>(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();
 }