]> git.lyx.org Git - features.git/commitdiff
Do not kill the undo stack when doing a Save As...
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 18 Jul 2012 08:31:47 +0000 (10:31 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 18 Jul 2012 08:31:47 +0000 (10:31 +0200)
The code does a reload on the buffer to avoid loose pointers if the
file changes directory. This commit adds a bool parameter to
Buffer::reload to allow for keeping the undo stack intact. This is of
couse only wanted in this case, not when reloading an earlier version
of the file.

src/Buffer.cpp
src/Buffer.h
src/frontends/qt4/GuiView.cpp

index f2c3501dc00a6780b56cac1110d58dd43831af7e..28bca5b1db09c45a3420d010b07dc1fe26fd632a 100644 (file)
@@ -4580,7 +4580,7 @@ int Buffer::charCount(bool with_blanks) const
 }
 
 
-Buffer::ReadStatus Buffer::reload()
+Buffer::ReadStatus Buffer::reload(bool clearUndo)
 {
        setBusy(true);
        // c.f. bug http://www.lyx.org/trac/ticket/6587
@@ -4598,7 +4598,8 @@ Buffer::ReadStatus Buffer::reload()
                updateTitles();
                markClean();
                message(bformat(_("Document %1$s reloaded."), disp_fn));
-               d->undo_.clear();
+               if (clearUndo)
+                       d->undo_.clear();
        } else {
                message(bformat(_("Could not reload document %1$s."), disp_fn));
        }
index fc02c6a05d3c7985f87b94a4e44a20c6d8efcc6c..f13a879b108a834c0ef2235dca039db37e5b90d7 100644 (file)
@@ -225,7 +225,8 @@ public:
        /// read a new document from a string
        bool readString(std::string const &);
        /// Reloads the LyX file
-       ReadStatus reload();
+       /// \param clearUndo if false, leave alone the undo stack.
+       ReadStatus reload(bool clearUndo = true);
 //FIXME: The following function should be private
 //private:
        /// read the header, returns number of unknown tokens
index 52a4379fa71befdac8d4c6279a11aa120ef65862..0237cb850867375395d30b9880a7a3ef15b14427 100644 (file)
@@ -2320,7 +2320,7 @@ bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
 
        bool const saved = saveBuffer(b, fname);
        if (saved)
-               b.reload();
+               b.reload(false);
        return saved;
 }