]> git.lyx.org Git - features.git/commitdiff
Fix bug #7796 (LyX creates file on startup that cannot be deleted)
authorEnrico Forestieri <forenr@lyx.org>
Tue, 27 Sep 2011 20:07:41 +0000 (20:07 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Tue, 27 Sep 2011 20:07:41 +0000 (20:07 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39779 a592a061-630c-0410-9148-cb99ea01b6c8

src/LyXRC.cpp

index d5b62eb7b8789ffdaccd422b1029870bb2048e3a..b678af0a8bc72c37c8977c178029765412695cc3 100644 (file)
@@ -402,11 +402,15 @@ bool LyXRC::read(FileName const & filename, bool check_format)
                LYXERR0 ("Unable to convert " << filename.absFileName() <<
                        " to format " << LYXRC_FILEFORMAT);
                return false;
+       } else {
+               // Keep this in the else branch, such that lexrc2 goes out
+               // of scope and releases the lock on tempfile before we
+               // attempt to remove it. This matters on Windows.
+               Lexer lexrc2(lyxrcTags);
+               lexrc2.setFile(tempfile);
+               LYXERR(Debug::LYXRC, "Reading '" << tempfile << "'...");
+               retval = read(lexrc2, check_format);
        }
-       Lexer lexrc2(lyxrcTags);
-       lexrc2.setFile(tempfile);
-       LYXERR(Debug::LYXRC, "Reading '" << tempfile << "'...");
-       retval = read(lexrc2, check_format);
        tempfile.removeFile();
        return retval == ReadOK;
 }