sa...@lyx.org wrote:
> Author: sanda
> Date: Tue Nov 24 19:47:43 2009
> New Revision: 32179
> URL: http://www.lyx.org/trac/changeset/32179
> 
> Log:
> 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.
> 
> Modified:
>    lyx-devel/trunk/src/frontends/qt4/GuiView.cpp
>    lyx-devel/trunk/src/frontends/qt4/GuiView.h

1.6.6?

> 
> Modified: lyx-devel/trunk/src/frontends/qt4/GuiView.cpp
> ==============================================================================
> --- lyx-devel/trunk/src/frontends/qt4/GuiView.cpp     Tue Nov 24 18:55:30 
> 2009        (r32178)
> +++ lyx-devel/trunk/src/frontends/qt4/GuiView.cpp     Tue Nov 24 19:47:43 
> 2009        (r32179)
> @@ -2259,6 +2259,12 @@
>  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::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 @@
>               if (ensureBufferClean(buffer)) {
>                       string res = buffer->lyxvc().repoUpdate();
>                       message(from_utf8(res));
> -                     reloadBuffer();
> +                     checkExternallyModifiedBuffers();
>               }
>               break;
>  
> 
> Modified: lyx-devel/trunk/src/frontends/qt4/GuiView.h
> ==============================================================================
> --- lyx-devel/trunk/src/frontends/qt4/GuiView.h       Tue Nov 24 18:55:30 
> 2009        (r32178)
> +++ lyx-devel/trunk/src/frontends/qt4/GuiView.h       Tue Nov 24 19:47:43 
> 2009        (r32179)
> @@ -126,6 +126,9 @@
>       /// 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 @@
>       Dialog * build(std::string const & name);
>       ///
>       void reloadBuffer();
> +     void reloadBuffer(Buffer * buf);
>       ///
>       void dispatchVC(FuncRequest const & cmd);
>       ///

Reply via email to