From 8e7bbcba29cabe45122f57260cad75b83556d6c0 Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Thu, 4 May 2006 02:38:11 +0000 Subject: [PATCH] A small fix to the auto-cls-layout feature (r13611), by Bo Peng (ben.bob@gmail.com) * src/lyxtextclass.[hC] improve load(path) function. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13795 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/lyxtextclass.C | 15 +++++++++------ src/lyxtextclass.h | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/lyxtextclass.C b/src/lyxtextclass.C index 1790d979b6..5d87cf1823 100644 --- a/src/lyxtextclass.C +++ b/src/lyxtextclass.C @@ -34,6 +34,7 @@ using lyx::support::makeDisplayPath; using lyx::support::quoteName; using lyx::support::rtrim; using lyx::support::subst; +using lyx::support::addName; using std::endl; using std::find_if; @@ -917,15 +918,17 @@ bool LyXTextClass::load(string const & path) const if (loaded_) return true; - // Read style-file, current directory is searched before system ones - string real_file = path + "/" + name_ + ".layout"; - if (!fs::exists(real_file)) - real_file = libFileSearch("layouts", name_, "layout"); - loaded_ = const_cast(this)->read(real_file) == 0; + // Read style-file, provided path is searched before the system ones + string layout_file; + if (!path.empty()) + layout_file = addName(path, name_ + ".layout"); + if (layout_file.empty() || !fs::exists(layout_file)) + layout_file = libFileSearch("layouts", name_, "layout"); + loaded_ = const_cast(this)->read(layout_file) == 0; if (!loaded_) { lyxerr << "Error reading `" - << makeDisplayPath(real_file) + << makeDisplayPath(layout_file) << "'\n(Check `" << name_ << "')\nCheck your installation and " "try Options/Reconfigure..." << endl; diff --git a/src/lyxtextclass.h b/src/lyxtextclass.h index 7d34e5032c..57345d8353 100644 --- a/src/lyxtextclass.h +++ b/src/lyxtextclass.h @@ -84,7 +84,7 @@ public: LyXLayout_ptr const & operator[](std::string const & vname) const; /// Sees to that the textclass structure has been loaded - bool load(std::string const & path=".") const; + bool load(std::string const & path=std::string()) const; /// Has this layout file been loaded yet? bool loaded() const { return loaded_; } -- 2.39.2