Fix reloading of local layout file (bug #11120)

This commit is contained in:
Enrico Forestieri 2018-11-16 21:47:24 +01:00
parent 0964ffb266
commit 7822d11361
4 changed files with 11 additions and 9 deletions

View File

@ -2453,7 +2453,7 @@ void BufferParams::setDocumentClass(DocumentClassConstPtr tc)
} }
bool BufferParams::setBaseClass(string const & classname) bool BufferParams::setBaseClass(string const & classname, string const & path)
{ {
LYXERR(Debug::TCLASS, "setBaseClass: " << classname); LYXERR(Debug::TCLASS, "setBaseClass: " << classname);
LayoutFileList & bcl = LayoutFileList::get(); LayoutFileList & bcl = LayoutFileList::get();
@ -2469,7 +2469,7 @@ bool BufferParams::setBaseClass(string const & classname)
bcl.addEmptyClass(classname); bcl.addEmptyClass(classname);
} }
bool const success = bcl[classname].load(); bool const success = bcl[classname].load(path);
if (!success) { if (!success) {
docstring s = docstring s =
bformat(_("Due to some error in it, the layout file:\n" bformat(_("Due to some error in it, the layout file:\n"

View File

@ -136,7 +136,9 @@ public:
/// NOTE: This does not call makeDocumentClass() to update the local /// NOTE: This does not call makeDocumentClass() to update the local
/// DocumentClass. That needs to be done manually. /// DocumentClass. That needs to be done manually.
/// \param classname: the name of the layout file /// \param classname: the name of the layout file
bool setBaseClass(std::string const & classname); /// \param path: non-empty only for local layout files
bool setBaseClass(std::string const & classname,
std::string const & path = std::string());
/// Adds the module information to the baseClass information to /// Adds the module information to the baseClass information to
/// create our local DocumentClass. /// create our local DocumentClass.
/// NOTE: This should NEVER be called externally unless one immediately goes /// NOTE: This should NEVER be called externally unless one immediately goes

View File

@ -1366,7 +1366,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
// without calling recordUndo. Fix this before using // without calling recordUndo. Fix this before using
// recordUndoBufferParams(). // recordUndoBufferParams().
cur.recordUndoFullBuffer(); cur.recordUndoFullBuffer();
buffer_.params().setBaseClass(argument); buffer_.params().setBaseClass(argument, buffer_.layoutPos());
makeDocumentClass(); makeDocumentClass();
dr.screenUpdate(Update::Force); dr.screenUpdate(Update::Force);
dr.forceBufferUpdate(); dr.forceBufferUpdate();
@ -1390,7 +1390,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
case LFUN_LAYOUT_RELOAD: { case LFUN_LAYOUT_RELOAD: {
LayoutFileIndex bc = buffer_.params().baseClassID(); LayoutFileIndex bc = buffer_.params().baseClassID();
LayoutFileList::get().reset(bc); LayoutFileList::get().reset(bc);
buffer_.params().setBaseClass(bc); buffer_.params().setBaseClass(bc, buffer_.layoutPos());
makeDocumentClass(); makeDocumentClass();
dr.screenUpdate(Update::Force); dr.screenUpdate(Update::Force);
dr.forceBufferUpdate(); dr.forceBufferUpdate();

View File

@ -2555,7 +2555,7 @@ void GuiDocument::classChanged()
// according to the new class. Note, however, that, if you use // according to the new class. Note, however, that, if you use
// the scroll wheel when sitting on the combo box, we'll load a // the scroll wheel when sitting on the combo box, we'll load a
// lot of TextClass objects very quickly.... // lot of TextClass objects very quickly....
if (!bp_.setBaseClass(classname)) { if (!bp_.setBaseClass(classname, buffer().layoutPos())) {
Alert::error(_("Error"), _("Unable to set document class.")); Alert::error(_("Error"), _("Unable to set document class."));
return; return;
} }
@ -2975,7 +2975,7 @@ void GuiDocument::updateDefaultFormat()
int const idx = latexModule->classCO->currentIndex(); int const idx = latexModule->classCO->currentIndex();
if (idx >= 0) { if (idx >= 0) {
string const classname = fromqstr(latexModule->classCO->getData(idx)); string const classname = fromqstr(latexModule->classCO->getData(idx));
param_copy.setBaseClass(classname); param_copy.setBaseClass(classname, buffer().layoutPos());
param_copy.makeDocumentClass(true); param_copy.makeDocumentClass(true);
} }
outputModule->defaultFormatCO->blockSignals(true); outputModule->defaultFormatCO->blockSignals(true);
@ -3133,7 +3133,7 @@ void GuiDocument::applyView()
int idx = latexModule->classCO->currentIndex(); int idx = latexModule->classCO->currentIndex();
if (idx >= 0) { if (idx >= 0) {
string const classname = fromqstr(latexModule->classCO->getData(idx)); string const classname = fromqstr(latexModule->classCO->getData(idx));
bp_.setBaseClass(classname); bp_.setBaseClass(classname, buffer().layoutPos());
} }
// Modules // Modules
@ -4330,7 +4330,7 @@ void GuiDocument::useClassDefaults()
int idx = latexModule->classCO->currentIndex(); int idx = latexModule->classCO->currentIndex();
string const classname = fromqstr(latexModule->classCO->getData(idx)); string const classname = fromqstr(latexModule->classCO->getData(idx));
if (!bp_.setBaseClass(classname)) { if (!bp_.setBaseClass(classname, buffer().layoutPos())) {
Alert::error(_("Error"), _("Unable to set document class.")); Alert::error(_("Error"), _("Unable to set document class."));
return; return;
} }