From: Pavel Sanda Date: Tue, 24 Nov 2009 18:47:43 +0000 (+0000) Subject: Fix #5211 - Check documents for changes after svn update. X-Git-Tag: 2.0.0~5030 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=0787e61c3ff68aa76699c82d47534ace05bf71b1;p=features.git Fix #5211 - Check documents for changes after svn update. 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 --- diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index c17fa83adc..d5aede6382 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -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; diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index e72b1802fa..869107b0f8 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -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); ///