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

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37243 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2011-01-17 15:54:51 +00:00
parent eb353f1b58
commit 0de73b8866
5 changed files with 30 additions and 28 deletions

View File

@ -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;
}
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'

View File

@ -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.

View File

@ -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;
}

View File

@ -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<std::string> CommandSet;

View File

@ -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();