]> git.lyx.org Git - features.git/commitdiff
fix crash bug with non-existing input files
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 13 Jan 2002 21:35:50 +0000 (21:35 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 13 Jan 2002 21:35:50 +0000 (21:35 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3360 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/bufferlist.C
src/insets/ChangeLog
src/insets/insetinclude.C

index e83de61a16e5a9d3d5ded96da96b220f78525fe2..b23fdf97a7418b7f8e28c572a24858aadf401b74 100644 (file)
@@ -1,5 +1,8 @@
 2002-01-13  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
 
+       * bufferlist.C (readFile): create the buffer _after_ checking that
+       the file exists.
+
        * lyxfunc.C (verboseDispatch): fix handling of arguments
 
        * lyxrc.C (setDefaults): do not initialize document_path to $HOME.
index 2d5695f64c531eb5dd7789e29758bea72bad4393..8fd835dd35188f38cca2bfec5afbed46d74e27b3 100644 (file)
@@ -357,8 +357,6 @@ void BufferList::emergencyWrite(Buffer * buf)
 
 Buffer * BufferList::readFile(string const & s, bool ronly)
 {
-       Buffer * b = bstore.newBuffer(s, ronly);
-
        string ts(s);
        string e = OnlyPath(s);
        string a = e;
@@ -371,6 +369,8 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
                return 0;
        }
  
+       Buffer * b = bstore.newBuffer(s, ronly);
+
        // Check if emergency save file exists and is newer.
        e += OnlyFilename(s) + ".emergency";
        FileInfo fileInfoE(e);
index 370fb1b5148b0f363619c49a19634db0cc1a9d6d..f5300b8cd3fa5c9745146524b8f895ec0476c6f0 100644 (file)
@@ -1,5 +1,8 @@
 2002-01-13  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
 
+       * insetinclude.C (loadIfNeeded): do not call bufferlist.readFile
+       if file does not exist
+
        * figinset.C (browseFile): add shortcuts to directory buttons
 
        * insettext.C (updateLocal): update menubar and toolbar here too.
index a7f28753ad4df16b3b64488ad8575d86f1c4562e..e4f207a1a549a13a44a56cb3e5d983ca0d0e1266 100644 (file)
@@ -218,8 +218,10 @@ bool InsetInclude::loadIfNeeded() const
        
        // the readonly flag can/will be wrong, not anymore I think.
        FileInfo finfo(getFileName());
-       bool const ro = !(!finfo.isOK() || finfo.writable());
-       return bufferlist.readFile(getFileName(), ro) != 0;
+       if (!finfo.isOK())
+               return false;
+       
+       return bufferlist.readFile(getFileName(), !finfo.writable()) != 0;
 }