]> git.lyx.org Git - lyx.git/blobdiff - src/buffer_funcs.cpp
Merge branch 'master' of git.lyx.org:lyx
[lyx.git] / src / buffer_funcs.cpp
index d096eeb09b76a8f9de518b96fd7285e408656edb..03ecc90abeb9d9a8bea5c4ec654ac38fde923016 100644 (file)
@@ -47,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;
@@ -73,13 +74,22 @@ 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, 1, 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;
        }
 
        bool const exists = filename.exists();
@@ -164,7 +174,9 @@ Buffer * newUnnamedFile(FileName const & path, string const & prefix,
                                                string const & templatename)
 {
        static map<string, int> file_number;
+       static Mutex mutex;
 
+       Mutex::Locker locker(&mutex);
        FileName filename;
 
        do {