X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fbuffer_funcs.cpp;h=03ecc90abeb9d9a8bea5c4ec654ac38fde923016;hb=2ebd535e99ebd1578209bf3e5890b06871e1dfeb;hp=073ddcb6f46f33c14d376a21cfc99eccba9be8a1;hpb=42dfd711977353e892aadbea6f531e59b0d92179;p=lyx.git diff --git a/src/buffer_funcs.cpp b/src/buffer_funcs.cpp index 073ddcb6f4..03ecc90abe 100644 --- a/src/buffer_funcs.cpp +++ b/src/buffer_funcs.cpp @@ -26,6 +26,7 @@ #include "LaTeX.h" #include "Layout.h" #include "LyX.h" +#include "LyXVC.h" #include "TextClass.h" #include "Paragraph.h" #include "ParagraphList.h" @@ -46,6 +47,7 @@ #include "support/filetools.h" #include "support/gettext.h" #include "support/lstrings.h" +#include "support/mutex.h" #include "support/textutils.h" using namespace std; @@ -72,17 +74,28 @@ Buffer * checkAndLoadLyXFile(FileName const & filename, bool const acceptDirty) docstring const text = bformat(_( "The document %1$s is already loaded and has unsaved changes.\n" "Do you want to abandon your changes and reload the version on disk?"), file); - if (!Alert::prompt(_("Reload saved document?"), - text, 0, 1, _("&Reload"), _("&Keep Changes"))) { - // reload the document - if (checkBuffer->reload() != Buffer::ReadSuccess) + int res = Alert::prompt(_("Reload saved document?"), + text, 2, 2, _("Yes, &Reload"), _("No, &Keep Changes"), _("&Cancel")); + switch (res) { + case 0: { + // reload the document + if (checkBuffer->reload() != Buffer::ReadSuccess) + return 0; + return checkBuffer; + } + case 1: + // keep changes + return checkBuffer; + case 2: + // cancel return 0; } - return checkBuffer; } - if (filename.exists()) { - if (!filename.isReadableFile()) { + bool const exists = filename.exists(); + bool const tryVC = exists ? false : LyXVC::fileInVC(filename); + if (exists || tryVC) { + if (exists && !filename.isReadableFile()) { docstring text = bformat(_("The file %1$s exists but is not " "readable by the current user."), from_utf8(filename.absFileName())); @@ -161,7 +174,9 @@ Buffer * newUnnamedFile(FileName const & path, string const & prefix, string const & templatename) { static map file_number; + static Mutex mutex; + Mutex::Locker locker(&mutex); FileName filename; do { @@ -178,7 +193,7 @@ Buffer * loadIfNeeded(FileName const & fname) { Buffer * buffer = theBufferList().getBuffer(fname); if (!buffer) { - if (!fname.exists()) + if (!fname.exists() && !LyXVC::fileInVC(fname)) return 0; buffer = theBufferList().newBuffer(fname.absFileName());