mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-08 10:51:03 +00:00
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
This commit is contained in:
parent
1a63ca7ca0
commit
0787e61c3f
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user