]> git.lyx.org Git - features.git/commitdiff
Load local textclass in addTextClass(), reload local layout correctly in LFUN_TEXTCLA...
authorBo Peng <bpeng@lyx.org>
Sun, 24 Feb 2008 06:14:48 +0000 (06:14 +0000)
committerBo Peng <bpeng@lyx.org>
Sun, 24 Feb 2008 06:14:48 +0000 (06:14 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23175 a592a061-630c-0410-9148-cb99ea01b6c8

src/LyXFunc.cpp
src/TextClass.cpp
src/TextClassList.cpp

index a9020fbf13d2bf037a19dfbf2ffa63183151e433..45658cf68b4906769078daa83457e1e577f07dd5 100644 (file)
@@ -712,7 +712,7 @@ void showPrintError(string const & name)
 }
 
 
-void loadTextClass(string const & name)
+void loadTextClass(string const & name, string const & buf_path)
 {
        pair<bool, TextClassIndex> 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<bool, TextClassIndex> 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: {
index 4df69a680c82375f2b45e84b6d37af3b57e929c0..8a308b35bad78465bc6cc23db38b3706a3231d0a 100644 (file)
@@ -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<TextClass*>(this)->load();
        return latexname_;
 }
index e1f3a27f5774d814cf8d0d6a68f38dda24e25683..8a2f86923917a652dc0a9bf2e5f6c55ace7f2f4a 100644 (file)
@@ -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);
                        }
                }