]> git.lyx.org Git - features.git/commitdiff
Fix bug #7044: Better error messages when modules are unavailable. Patch
authorRichard Heck <rgheck@comcast.net>
Thu, 13 Jan 2011 21:19:14 +0000 (21:19 +0000)
committerRichard Heck <rgheck@comcast.net>
Thu, 13 Jan 2011 21:19:14 +0000 (21:19 +0000)
from Julien Rioux, modified by me.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37207 a592a061-630c-0410-9148-cb99ea01b6c8

src/ModuleList.cpp
src/ModuleList.h
src/TextClass.cpp

index 4ed97de91431d8e23a91a366252edd04717b8012..a9658710029e440959749bd48b9f0902f63070d7 100644 (file)
@@ -45,6 +45,17 @@ LyXModule::LyXModule(string const & n, string const & i,
 }
 
 
+vector<string> LyXModule::prerequisites() const {
+#ifdef TEX2LYX
+       return vector<string>();
+#else
+       if (!checked_)
+               isAvailable();
+       return prerequisites_;
+#endif
+}
+
+
 bool LyXModule::isAvailable() const {
 #ifdef TEX2LYX
        return true;
@@ -54,16 +65,16 @@ bool LyXModule::isAvailable() const {
        if (checked_)
                return available_;
        checked_ = true;
+       available_ = true;
        //check whether all of the required packages are available
        vector<string>::const_iterator it  = package_list_.begin();
        vector<string>::const_iterator end = package_list_.end(); 
        for (; it != end; ++it) {
                if (!LaTeXFeatures::isAvailable(*it)) {
                        available_ = false;
-                       return available_;
+                       prerequisites_.push_back(*it);
                }
        }
-       available_ = true;
        return available_;
 #endif
 }
index c9a6f1f4d7effbf8068206bd2fd281b02621de60..d3abef913a5450830365451e6f71c1f5697ed099 100644 (file)
@@ -58,6 +58,8 @@ public:
                  std::string const & catgy);
        /// whether the required packages are available
        bool isAvailable() const;
+       /// the missing prerequisites, if any
+       std::vector<std::string> prerequisites() const;
        ///
        std::string const & getName() const { return name_; }
        ///
@@ -108,6 +110,8 @@ private:
        mutable bool checked_;
        ///
        mutable bool available_;
+       ///
+       mutable std::vector<std::string> prerequisites_;
 };
 
 typedef std::vector<LyXModule> LyXModuleList;
index a43ad9edf9019d67fd7c88ef2dc14f6c9314c9f8..750d554001f505b0a6c7daccb8e2bc57357376f6 100644 (file)
@@ -1308,11 +1308,15 @@ DocumentClass & DocumentClassBundle::makeDocumentClass(
                        continue;
                }
                if (!lm->isAvailable()) {
+                       docstring const prereqs = from_utf8(getStringFromVector(lm->prerequisites(), "\n\t"));
                        docstring const msg =
-                               bformat(_("The module %1$s requires a package that is\n"
-                               "not available in your LaTeX installation, or a converter\n"
-                               "you have not installed. LaTeX output may not be possible.\n"), 
-                               from_utf8(modName));
+                               bformat(_("The module %1$s requires a package that is not\n"
+                                       "available in your LaTeX installation, or a converter that\n"
+                                       "you have not installed. LaTeX output may not be possible.\n"
+                                       "Missing prerequisites:\n"
+                                               "\t%2$s\n"
+                                       "See section 3.1.2.3 of the User's Guide for more information."),
+                               from_utf8(modName), prereqs);
                        frontend::Alert::warning(_("Package not available"), msg);
                }
                FileName layout_file = libFileSearch("layouts", lm->getFilename());