Juergen Spitzmueller <[EMAIL PROTECTED]> writes:

| Jean-Marc Lasgouttes wrote:
| > You can apply, then.
| 
| After some more testing of the OP, it turned out that the crash actually 
| occurs if the directory where the bib file lives is not readable. I can 
| reproduce the crash, and the attached patch fixes it.
| 
| OK?

I'd probably go a bit further.
(On the principle "Just try to do what ever you want to do and handle
the failure if it arises.")
(and "Avoid filesystem race-conditions if you can.")

Index: insetcite.C
===================================================================
--- insetcite.C (revision 14808)
+++ insetcite.C (working copy)
@@ -27,6 +27,7 @@
 #include "support/lstrings.h"

 #include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/exception.hpp>

 using lyx::support::ascii_lowercase;
 using lyx::support::contains;
@@ -71,12 +72,19 @@
        for (vector<string>::const_iterator it = bibfilesCache.begin();
                        it != bibfilesCache.end(); ++ it) {
                string const f = *it;
-               if (!fs::exists(f) || 
!fs::is_readable(fs::path(f).branch_path())) {
-                       lyxerr << "Couldn't find or read bibtex file " << f << 
endl;
+               try {
+                       std::time_t lastw = fs::last_write_time(f);
+                       if (lastw != bibfileStatus[f]) {
                        changed = true;
-               } else if (bibfileStatus[f] != fs::last_write_time(f)) {
+                               bibfileStatus[f] = lastw;
+                       }
+               }
+               catch (fs::filesystem_error & fserr) {
                        changed = true;
-                       bibfileStatus[f] = fs::last_write_time(f);
+                       lyxerr << "Couldn't find or read bibtex file "
+                              << f << endl;
+                       lyxerr[Debug::DEBUG] << "Fs error: "
+                                            << fserr.what() << endl;
                }
        }


Can you try this one Jurgen?

-- 
        Lgb

Reply via email to