Author: rgheck
Date: Mon Jan 17 16:54:51 2011
New Revision: 37243
URL: http://www.lyx.org/trac/changeset/37243

Log:
Don't try to convert any of the preference files except the user's own.

Modified:
   lyx-devel/trunk/src/LyX.cpp
   lyx-devel/trunk/src/LyX.h
   lyx-devel/trunk/src/LyXRC.cpp
   lyx-devel/trunk/src/LyXRC.h
   lyx-devel/trunk/src/frontends/qt4/GuiApplication.cpp

Modified: lyx-devel/trunk/src/LyX.cpp
==============================================================================
--- lyx-devel/trunk/src/LyX.cpp Mon Jan 17 16:07:54 2011        (r37242)
+++ lyx-devel/trunk/src/LyX.cpp Mon Jan 17 16:54:51 2011        (r37243)
@@ -806,7 +806,7 @@
        system_lcolor = lcolor;
 
        // This one is edited through the preferences dialog.
-       if (!readRcFile("preferences"))
+       if (!readRcFile("preferences", true))
                return false;
 
        if (!readEncodingsFile("encodings", "unicodesymbols"))
@@ -960,21 +960,22 @@
 }
 
 
-bool LyX::readRcFile(string const & name)
+bool LyX::readRcFile(string const & name, bool check_format)
 {
        LYXERR(Debug::INIT, "About to read " << name << "... ");
 
        FileName const lyxrc_path = libFileSearch(string(), name);
-       if (!lyxrc_path.empty()) {
-               LYXERR(Debug::INIT, "Found in " << lyxrc_path);
-               if (!lyxrc.read(lyxrc_path)) {
-                       showFileError(name);
-                       return false;
-               }
-       } else {
+       if (lyxrc_path.empty()) {
                LYXERR(Debug::INIT, "Not found." << lyxrc_path);
-       }
-       return true;
+               // FIXME
+               // This was the previous logic, but can it be right??
+               return true;
+       }
+       LYXERR(Debug::INIT, "Found in " << lyxrc_path);
+       bool const success = lyxrc.read(lyxrc_path, check_format);
+       if (!success)
+               showFileError(name);
+       return success;
 }
 
 // Read the languages file `name'

Modified: lyx-devel/trunk/src/LyX.h
==============================================================================
--- lyx-devel/trunk/src/LyX.h   Mon Jan 17 16:07:54 2011        (r37242)
+++ lyx-devel/trunk/src/LyX.h   Mon Jan 17 16:54:51 2011        (r37243)
@@ -108,7 +108,9 @@
         */
        bool queryUserLyXDir(bool explicit_userdir);
        /// read lyxrc/preferences
-       bool readRcFile(std::string const & name);
+       /// \param check_format: whether to try to convert the format of
+       /// the file, if there is a mismatch.
+       bool readRcFile(std::string const & name, bool check_format = false);
        /// read the given languages file
        bool readLanguagesFile(std::string const & name);
        /// read the encodings.

Modified: lyx-devel/trunk/src/LyXRC.cpp
==============================================================================
--- lyx-devel/trunk/src/LyXRC.cpp       Mon Jan 17 16:07:54 2011        (r37242)
+++ lyx-devel/trunk/src/LyXRC.cpp       Mon Jan 17 16:54:51 2011        (r37243)
@@ -377,13 +377,13 @@
 } // namespace anon
 
 
-bool LyXRC::read(FileName const & filename)
+bool LyXRC::read(FileName const & filename, bool check_format)
 {
        Lexer lexrc(lyxrcTags);
        lexrc.setFile(filename);
        LYXERR(Debug::LYXRC, "Reading '" << filename << "'...");
-       ReturnValues retval = read(lexrc);
-       if (retval != FormatMismatch)
+       ReturnValues retval = read(lexrc, check_format);
+       if (!check_format || retval != FormatMismatch)
                return retval == ReadOK;
 
        LYXERR(Debug::FILES, "Converting LyXRC file to " << LYXRC_FILEFORMAT);
@@ -397,7 +397,7 @@
        Lexer lexrc2(lyxrcTags);
        lexrc2.setFile(tempfile);
        LYXERR(Debug::LYXRC, "Reading '" << tempfile << "'...");
-       retval = read(lexrc2);
+       retval = read(lexrc2, check_format);
        tempfile.removeFile();
        return retval == ReadOK;
 }
@@ -410,11 +410,11 @@
        Lexer lexrc(lyxrcTags);
        lexrc.setStream(is);
        LYXERR(Debug::LYXRC, "Reading istream...");
-       return read(lexrc) == ReadOK;
+       return read(lexrc, false) == ReadOK;
 }
 
 
-LyXRC::ReturnValues LyXRC::read(Lexer & lexrc)
+LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
 {
        if (lyxerr.debugging(Debug::PARSER))
                lexrc.printTable(lyxerr);
@@ -453,9 +453,9 @@
                                FileName const tmp =
                                        libFileSearch(string(),
                                                      lexrc.getString());
-                               if (read(tmp)) {
-                                       lexrc.printError("Error reading "
-                                                        "included file: " + 
tmp.absFileName());
+                               if (read(tmp, check_format)) {
+                                       lexrc.printError(
+                                           "Error reading included file: " + 
tmp.absFileName());
                                }
                        }
                        break;
@@ -1262,7 +1262,7 @@
 
                // This is triggered the first time through the loop unless
                // we hit a format tag.
-               if (format != LYXRC_FILEFORMAT)
+               if (check_format && format != LYXRC_FILEFORMAT)
                        return FormatMismatch;
        }
 

Modified: lyx-devel/trunk/src/LyXRC.h
==============================================================================
--- lyx-devel/trunk/src/LyXRC.h Mon Jan 17 16:07:54 2011        (r37242)
+++ lyx-devel/trunk/src/LyXRC.h Mon Jan 17 16:54:51 2011        (r37243)
@@ -191,21 +191,20 @@
        LyXRC();
        ///
        void setDefaults();
-       ///
-       bool read(support::FileName const & filename);
+       /// \param check_format: whether to try to convert the file format,
+       /// if it is not current. this should only be true, really, for the
+       /// user's own preferences file.
+       bool read(support::FileName const & filename, bool check_format);
        ///
        bool read(std::istream &);
 private:
        enum ReturnValues {
                ReadOK,
-               FileError,
                ReadError,
                FormatMismatch
        };
        ///
-       ReturnValues readWithoutConv(support::FileName const &);
-       ///
-       ReturnValues read(Lexer &);
+       ReturnValues read(Lexer &, bool check_format);
 public:
        ///
        typedef std::set<std::string> CommandSet;

Modified: lyx-devel/trunk/src/frontends/qt4/GuiApplication.cpp
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiApplication.cpp        Mon Jan 17 
16:07:54 2011        (r37242)
+++ lyx-devel/trunk/src/frontends/qt4/GuiApplication.cpp        Mon Jan 17 
16:54:51 2011        (r37243)
@@ -1220,7 +1220,7 @@
        // emit message signal.
        if (current_view_)
                current_view_->message(_("Reloading configuration..."));
-       lyxrc.read(libFileSearch(QString(), "lyxrc.defaults"));
+       lyxrc.read(libFileSearch(QString(), "lyxrc.defaults"), false);
        // Re-read packages.lst
        LaTeXFeatures::getAvailable();
 

Reply via email to