From 28e08b23e27e9119e47d4425e3e6260cdcf31263 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Thu, 13 Jan 2011 21:19:14 +0000 Subject: [PATCH] Fix bug #7044: Better error messages when modules are unavailable. Patch 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 | 15 +++++++++++++-- src/ModuleList.h | 4 ++++ src/TextClass.cpp | 12 ++++++++---- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/ModuleList.cpp b/src/ModuleList.cpp index 4ed97de914..a965871002 100644 --- a/src/ModuleList.cpp +++ b/src/ModuleList.cpp @@ -45,6 +45,17 @@ LyXModule::LyXModule(string const & n, string const & i, } +vector LyXModule::prerequisites() const { +#ifdef TEX2LYX + return vector(); +#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::const_iterator it = package_list_.begin(); vector::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 } diff --git a/src/ModuleList.h b/src/ModuleList.h index c9a6f1f4d7..d3abef913a 100644 --- a/src/ModuleList.h +++ b/src/ModuleList.h @@ -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 prerequisites() const; /// std::string const & getName() const { return name_; } /// @@ -108,6 +110,8 @@ private: mutable bool checked_; /// mutable bool available_; + /// + mutable std::vector prerequisites_; }; typedef std::vector LyXModuleList; diff --git a/src/TextClass.cpp b/src/TextClass.cpp index a43ad9edf9..750d554001 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -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());