From: Bo Peng Date: Sun, 24 Feb 2008 06:14:48 +0000 (+0000) Subject: Load local textclass in addTextClass(), reload local layout correctly in LFUN_TEXTCLA... X-Git-Tag: 1.6.10~6126 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=1aaa96e6f1a0138f853139c0a3fc740c762fc960;p=features.git Load local textclass in addTextClass(), reload local layout correctly in LFUN_TEXTCLASS_APPLY and LFUN_TEXTCLASS_LOAD git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23175 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index a9020fbf13..45658cf68b 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -712,7 +712,7 @@ void showPrintError(string const & name) } -void loadTextClass(string const & name) +void loadTextClass(string const & name, string const & buf_path) { pair const tc_pair = textclasslist.numberOfClass(name); @@ -726,7 +726,7 @@ void loadTextClass(string const & name) TextClassIndex const tc = tc_pair.second; - if (!textclasslist[tc].load()) { + if (!textclasslist[tc].load(buf_path)) { docstring s = bformat(_("The document class %1$s." "could not be loaded."), from_utf8(textclasslist[tc].name())); @@ -1605,7 +1605,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) BOOST_ASSERT(lyx_view_); Buffer * buffer = lyx_view_->buffer(); - loadTextClass(argument); + loadTextClass(argument, buffer->filePath()); pair const tc_pair = textclasslist.numberOfClass(argument); @@ -1644,7 +1644,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) } case LFUN_TEXTCLASS_LOAD: - loadTextClass(argument); + loadTextClass(argument, lyx_view_->buffer()->filePath()); break; case LFUN_LYXRC_APPLY: { diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 4df69a680c..8a308b35ba 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -1010,6 +1010,8 @@ string const & TextClass::name() const string const & TextClass::latexname() const { + // No buffer path information is needed here because on-demand layout files + // have already been loaded, and no path is needed for system layouts. const_cast(this)->load(); return latexname_; } diff --git a/src/TextClassList.cpp b/src/TextClassList.cpp index e1f3a27f57..8a2f869239 100644 --- a/src/TextClassList.cpp +++ b/src/TextClassList.cpp @@ -151,6 +151,8 @@ bool TextClassList::read() // fname, clname, desc, and avail TextClass tmpl(fname, clname, desc, avail); if (lyxerr.debugging(Debug::TCLASS)) { + // only system layout files are loaded here so no + // buffer path is needed. tmpl.load(); } classlist_.push_back(tmpl); @@ -221,6 +223,10 @@ TextClassList::addTextClass(string const & textclass, string const & path) if (pp.first && classlist_[pp.second].description() == tmpl.description()) return pp; classlist_.push_back(tmpl); + // This textclass is added on request so it will definitely be + // used. Load it now because other load() calls may fail if they + // are called in a context without buffer path information. + classlist_.back().load(path); return make_pair(true, classlist_.size() - 1); } }