From: Richard Heck Date: Fri, 25 Jul 2008 16:48:48 +0000 (+0000) Subject: Move the default module loading from makeDocumentClass() to setBaseClass(). X-Git-Tag: 1.6.10~3880 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=a28c58406451504f3f946f65d3eb6b4fcc4b9b3c;p=features.git Move the default module loading from makeDocumentClass() to setBaseClass(). This makes the Document>Settings dialog behave better. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25882 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index bc818c39dd..2117e8059c 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1428,40 +1428,16 @@ bool BufferParams::setBaseClass(string const & classname) bcl.addEmptyClass(classname); } - if (bcl[classname].load()) { - pimpl_->baseClass_ = classname; - return true; + bool const success = bcl[classname].load(); + if (!success) { + docstring s = + bformat(_("The document class %1$s could not be loaded."), + from_utf8(classname)); + frontend::Alert::error(_("Could not load class"), s); + return false; } - - docstring s = - bformat(_("The document class %1$s could not be loaded."), - from_utf8(classname)); - frontend::Alert::error(_("Could not load class"), s); - return false; -} - - -LayoutFile const * BufferParams::baseClass() const -{ - if (LayoutFileList::get().haveClass(pimpl_->baseClass_)) - return &(LayoutFileList::get()[pimpl_->baseClass_]); - else - return 0; -} - -LayoutFileIndex const & BufferParams::baseClassID() const -{ - return pimpl_->baseClass_; -} - - -void BufferParams::makeDocumentClass() -{ - if (!baseClass()) - return; - - doc_class_ = &(DocumentClassBundle::get().newClass(*baseClass())); + pimpl_->baseClass_ = classname; // add any required modules not already in use set const & mods = baseClass()->defaultModules(); @@ -1497,7 +1473,32 @@ void BufferParams::makeDocumentClass() } } } - + return true; +} + + +LayoutFile const * BufferParams::baseClass() const +{ + if (LayoutFileList::get().haveClass(pimpl_->baseClass_)) + return &(LayoutFileList::get()[pimpl_->baseClass_]); + else + return 0; +} + + +LayoutFileIndex const & BufferParams::baseClassID() const +{ + return pimpl_->baseClass_; +} + + +void BufferParams::makeDocumentClass() +{ + if (!baseClass()) + return; + + doc_class_ = &(DocumentClassBundle::get().newClass(*baseClass())); + // FIXME It might be worth loading the children's modules here, // just as we load their bibliographies and such, instead of just // doing a check in InsetInclude. diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 15b51d3cf4..c5be6ef4e5 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -1323,6 +1323,11 @@ void GuiDocument::classChanged() bp_.useClassDefaults(); paramsToDialog(bp_); } + // FIXME There's a little bug here connected with auto_reset, namely, + // that, if the preceding is skipped and the user has changed the + // modules before changing the class, those changes will be lost on + // update. But maybe that's what we want? + updateSelectedModules(); }