diff --git a/src/LyX.cpp b/src/LyX.cpp index be2c159703..3f43e1d956 100644 --- a/src/LyX.cpp +++ b/src/LyX.cpp @@ -806,7 +806,7 @@ bool LyX::init() 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::queryUserLyXDir(bool explicit_userdir) } -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); + // FIXME + // This was the previous logic, but can it be right?? + return true; } - 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' diff --git a/src/LyX.h b/src/LyX.h index c9674eba37..4e66f2c196 100644 --- a/src/LyX.h +++ b/src/LyX.h @@ -108,7 +108,9 @@ private: */ 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. diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 487255f5fb..94edf17154 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -377,13 +377,13 @@ void oldFontFormat(string & family, string & foundry) } // 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 @@ bool LyXRC::read(FileName const & filename) 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 @@ bool LyXRC::read(istream & is) 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 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc) 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 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc) // 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; } diff --git a/src/LyXRC.h b/src/LyXRC.h index 4d4dcf6c5f..d94b861cb3 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -191,21 +191,20 @@ public: 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 CommandSet; diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 2ddcb0d214..e5e7765cb8 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -1220,7 +1220,7 @@ void GuiApplication::reconfigure(string const & option) // 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();