]> git.lyx.org Git - lyx.git/blobdiff - src/bufferlist.C
Fix working of the spellchecker dialog with ispell when there are no
[lyx.git] / src / bufferlist.C
index 36ba4b357d0e91f3eb467519b67cfc3f16aa39b9..c5af8316686d4dea579960ac7a608988cf70db86 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <config.h>
 
+#include <assert.h>
 #include <algorithm>
 #include <functional>
 
@@ -27,6 +28,7 @@
 #include "support/filetools.h"
 #include "support/lyxmanip.h"
 #include "support/lyxfunctional.h"
+#include "support/LAssert.h"
 #include "lyx_gui_misc.h"
 #include "lastfiles.h"
 #include "debug.h"
@@ -95,7 +97,7 @@ bool BufferList::empty() const
 }
 
 
-bool BufferList::QwriteAll()
+bool BufferList::qwriteAll()
 {
         bool askMoreConfirmation = false;
         string unsaved;
@@ -173,7 +175,7 @@ bool BufferList::close(Buffer * buf)
         if (buf->getUser()) buf->getUser()->insetUnlock();
        if (buf->paragraph && !buf->isLyxClean() && !quitting) {
                if (buf->getUser())
-                       ProhibitInput(buf->getUser());
+                       buf->getUser()->owner()->prohibitInput();
                string fname;
                if (buf->isUnnamed())
                        fname = OnlyFilename(buf->fileName());
@@ -192,7 +194,7 @@ bool BufferList::close(Buffer * buf)
                                        reask = false;
                                } else {
                                        if (buf->getUser())
-                                               AllowInput(buf->getUser());
+                                               buf->getUser()->owner()->allowInput();
                                        return false;
                                }
                                break;
@@ -204,12 +206,12 @@ bool BufferList::close(Buffer * buf)
                                break;
                        case 3: // Cancel
                                if (buf->getUser())
-                                       AllowInput(buf->getUser());
+                                       buf->getUser()->owner()->allowInput();
                                return false;
                        }
                }
                if (buf->getUser())
-                       AllowInput(buf->getUser());
+                       buf->getUser()->owner()->allowInput();
        }
 
        bstore.release(buf);
@@ -348,6 +350,12 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
        // File information about normal file
        FileInfo fileInfo2(s);
 
+       if (!fileInfo2.exist()) {
+               WriteAlert(_("Error!"), _("Cannot open file"), 
+                       MakeDisplayPath(s));
+               return 0;
+       }
        // Check if emergency save file exists and is newer.
        e += OnlyFilename(s) + ".emergency";
        FileInfo fileInfoE(e);
@@ -443,11 +451,11 @@ Buffer * BufferList::newFile(string const & name, string tname, bool isNamed)
        if (tname.empty()) {
                tname = LibFileSearch("templates", "defaults.lyx");
        }
-       if (!tname.empty() && IsLyXFilename(tname)) {
+       if (!tname.empty()) {
                bool templateok = false;
                LyXLex lex(0, 0);
                lex.setFile(tname);
-               if (lex.IsOK()) {
+               if (lex.isOK()) {
                        if (b->readFile(lex)) {
                                templateok = true;
                        }
@@ -475,8 +483,12 @@ Buffer * BufferList::newFile(string const & name, string tname, bool isNamed)
 
 Buffer * BufferList::loadLyXFile(string const & filename, bool tolastfiles)
 {
-       // make sure our path is absolute
-       string const s = MakeAbsPath(filename);
+       // get absolute path of file and add ".lyx" to the filename if
+       // necessary
+       string s = FileSearch(string(), filename, "lyx");
+       if (s.empty()) {
+               s = filename;
+       }
 
        // file already open?
        if (exists(s)) {