]> git.lyx.org Git - features.git/commitdiff
Fix crash when layout file cannot be read due to failure to call makeTextClass()...
authorRichard Heck <rgheck@comcast.net>
Sat, 8 Sep 2007 17:50:09 +0000 (17:50 +0000)
committerRichard Heck <rgheck@comcast.net>
Sat, 8 Sep 2007 17:50:09 +0000 (17:50 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20153 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/BufferParams.cpp

index bdf866fbe12d863ab711351cdfefe113a46e8490..a7bca7bd371d498cb5e050d5c2ec106451f920c2 100644 (file)
@@ -531,8 +531,9 @@ bool Buffer::readDocument(Lexer & lex)
        BOOST_ASSERT(paragraphs().empty());
 
        readHeader(lex);
-       if (!params().getTextClass().load(filePath())) {
-               string theclass = params().getTextClass().name();
+       TextClass const & baseClass = textclasslist[params().getBaseClass()];
+       if (!baseClass.load(filePath())) {
+               string theclass = baseClass.name();
                Alert::error(_("Can't load document class"), bformat(
                        _("Using the default document class, because the "
                                     "class %1$s could not be loaded."), from_utf8(theclass)));
index b78056b5298bc4cf1394ddfee6a5a8aa64a11c56..e566cdd822210626c6ab7f559a10a43fc548ba4b 100644 (file)
@@ -1227,17 +1227,18 @@ void BufferParams::setTextClass(TextClass_ptr tc) {
 
 bool BufferParams::setBaseClass(textclass_type tc)
 {
-       if (!textclasslist[tc].load()) {
-               docstring s = bformat(_("The document class %1$s."
-                                       "could not be loaded."),
+       bool retVal = true;
+       if (textclasslist[tc].load())
+               baseClass_ = tc;
+       else {
+               docstring s = 
+                       bformat(_("The document class %1$s could not be loaded."),
                 from_utf8(textclasslist[tc].name()));
                frontend::Alert::error(_("Could not load class"), s);
-               return false;
+               retVal = false;
        }
-       
-       baseClass_ = tc;
        makeTextClass();
-       return true;
+       return retVal;
 }