]> git.lyx.org Git - features.git/commitdiff
Fix #5211 - Check documents for changes after svn update.
authorPavel Sanda <sanda@lyx.org>
Tue, 24 Nov 2009 18:47:43 +0000 (18:47 +0000)
committerPavel Sanda <sanda@lyx.org>
Tue, 24 Nov 2009 18:47:43 +0000 (18:47 +0000)
This could be called regularly for usage with other programs too,
but I have no idea where. Dispatch is no good idea for performance reasons.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32179 a592a061-630c-0410-9148-cb99ea01b6c8

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

index c17fa83adc9b4ac0da5d799f144d25186cca9798..d5aede6382430084ab33acac73b0125148eccdc2 100644 (file)
@@ -2259,6 +2259,12 @@ static bool ensureBufferClean(Buffer * buffer)
 void GuiView::reloadBuffer()
 {
        Buffer * buf = &documentBufferView()->buffer();
+       reloadBuffer(buf);
+}
+
+
+void GuiView::reloadBuffer(Buffer * buf)
+{
        FileName filename = buf->fileName();
        Buffer const * master = buf->masterBuffer();
        bool const is_child = master != buf;
@@ -2284,6 +2290,24 @@ void GuiView::reloadBuffer()
 }
 
 
+void GuiView::checkExternallyModifiedBuffers()
+{
+       BufferList::iterator bit = theBufferList().begin();
+       BufferList::iterator const bend = theBufferList().end();
+       for (; bit != bend; ++bit) {
+               if ((*bit)->isExternallyModified(Buffer::checksum_method)) {
+                       docstring text = bformat(_("Document \n%1$s\n has been externally modified."
+                                       " Reload now? Any local changes will be lost."),
+                                       from_utf8((*bit)->absFileName()));
+                       int const ret = Alert::prompt(_("Reload externally changed document?"),
+                                               text, 0, 1, _("&Reload"), _("&Cancel"));
+                       if (!ret)
+                               reloadBuffer(*bit);
+               }
+       }
+}
+
+
 void GuiView::dispatchVC(FuncRequest const & cmd)
 {
        Buffer * buffer = documentBufferView()
@@ -2350,7 +2374,7 @@ void GuiView::dispatchVC(FuncRequest const & cmd)
                if (ensureBufferClean(buffer)) {
                        string res = buffer->lyxvc().repoUpdate();
                        message(from_utf8(res));
-                       reloadBuffer();
+                       checkExternallyModifiedBuffers();
                }
                break;
 
index e72b1802fadba7e552874bada17daf12886343b9..869107b0f80058b13a2c0c5c9605bc3ffc95e624 100644 (file)
@@ -126,6 +126,9 @@ public:
        /// called on timeout
        void autoSave();
 
+       /// check for external change of any opened buffer, mainly for svn usage
+       void checkExternallyModifiedBuffers();
+
        /** redraw \c inset in all the BufferViews in which it is currently
         *  visible. If successful return a pointer to the owning Buffer.
         */
@@ -340,6 +343,7 @@ private:
        Dialog * build(std::string const & name);
        ///
        void reloadBuffer();
+       void reloadBuffer(Buffer * buf);
        ///
        void dispatchVC(FuncRequest const & cmd);
        ///