Author: rgheck
Date: Thu Jan 13 22:19:14 2011
New Revision: 37207
URL: http://www.lyx.org/trac/changeset/37207

Log:
Fix bug #7044: Better error messages when modules are unavailable. Patch
from Julien Rioux, modified by me.

Modified:
   lyx-devel/trunk/src/ModuleList.cpp
   lyx-devel/trunk/src/ModuleList.h
   lyx-devel/trunk/src/TextClass.cpp

Modified: lyx-devel/trunk/src/ModuleList.cpp
==============================================================================
--- lyx-devel/trunk/src/ModuleList.cpp  Thu Jan 13 22:04:52 2011        (r37206)
+++ lyx-devel/trunk/src/ModuleList.cpp  Thu Jan 13 22:19:14 2011        (r37207)
@@ -45,6 +45,17 @@
 }
 
 
+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 @@
        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
 }

Modified: lyx-devel/trunk/src/ModuleList.h
==============================================================================
--- lyx-devel/trunk/src/ModuleList.h    Thu Jan 13 22:04:52 2011        (r37206)
+++ lyx-devel/trunk/src/ModuleList.h    Thu Jan 13 22:19:14 2011        (r37207)
@@ -58,6 +58,8 @@
                  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 @@
        mutable bool checked_;
        ///
        mutable bool available_;
+       ///
+       mutable std::vector<std::string> prerequisites_;
 };
 
 typedef std::vector<LyXModule> LyXModuleList;

Modified: lyx-devel/trunk/src/TextClass.cpp
==============================================================================
--- lyx-devel/trunk/src/TextClass.cpp   Thu Jan 13 22:04:52 2011        (r37206)
+++ lyx-devel/trunk/src/TextClass.cpp   Thu Jan 13 22:19:14 2011        (r37207)
@@ -1308,11 +1308,15 @@
                        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());

Reply via email to