changeset 1149:afed8be79032 3.0-integration

Show warning to the user when plugin population has problems
author Chris Cannam
date Tue, 19 Jan 2016 12:32:30 +0000
parents 9cdb4206aceb
children fc4cb3901316
files plugin/FeatureExtractionPluginFactory.cpp plugin/FeatureExtractionPluginFactory.h system/System.cpp transform/TransformFactory.cpp transform/TransformFactory.h
diffstat 5 files changed, 47 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/plugin/FeatureExtractionPluginFactory.cpp	Mon Jan 11 14:18:56 2016 +0000
+++ b/plugin/FeatureExtractionPluginFactory.cpp	Tue Jan 19 12:32:30 2016 +0000
@@ -136,7 +136,8 @@
 }
 
 vector<QString>
-FeatureExtractionPluginFactory::winnowPluginCandidates(vector<QString> candidates)
+FeatureExtractionPluginFactory::winnowPluginCandidates(vector<QString> candidates,
+                                                       QString &warningMessage)
 {
     vector<QString> good, bad;
     vector<PluginLoadStatus> badStatuses;
@@ -159,24 +160,26 @@
     }
     
     if (!bad.empty()) {
-        QString warningMessage = "<b>Failed to load plugins</b></p>Failed to load one or more plugin libraries:</p><ul>\n";
+        warningMessage =
+            QObject::tr("<b>Failed to load plugins</b>"
+                        "<p>Failed to load one or more plugin libraries:</p>\n");
+        warningMessage += "<ul>";
         for (int i = 0; i < bad.size(); ++i) {
             QString m;
             if (badStatuses[i] == PluginLoadFailedToLoadLibrary) {
-                m = "Failed to load library";
+                m = QObject::tr("Failed to load library");
             } else if (badStatuses[i] == PluginLoadFailedToFindDescriptor) {
-                m = "Failed to query plugins from library after loading";
+                m = QObject::tr("Failed to query plugins from library after loading");
             } else if (badStatuses[i] == PluginLoadFailedElsewhere) {
-                m = "Unknown failure";
+                m = QObject::tr("Unknown failure");
             } else {
-                m = "Success: internal error?";
+                m = QObject::tr("Success: internal error?");
             }
             warningMessage += QString("<li>%1 (%2)</li>\n")
                 .arg(bad[i])
                 .arg(m);
         }
         warningMessage += "</ul>";
-        cerr << warningMessage; //!!! for now!
     }
     return good;
 }
@@ -187,7 +190,8 @@
     Profiler profiler("FeatureExtractionPluginFactory::getPluginIdentifiers");
 
     vector<QString> rv;
-    vector<QString> candidates = winnowPluginCandidates(getPluginCandidateFiles());
+    vector<QString> candidates = winnowPluginCandidates(getPluginCandidateFiles(),
+                                                        m_pluginScanError);
     
     for (QString soname : candidates) {
 
@@ -236,7 +240,7 @@
                      << descriptor->identifier << "\" at indices "
                      << known[descriptor->identifier] << " and "
                      << index << endl;
-                SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl;
+                cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl;
                 ok = false;
                 break;
             } else {
--- a/plugin/FeatureExtractionPluginFactory.h	Mon Jan 11 14:18:56 2016 +0000
+++ b/plugin/FeatureExtractionPluginFactory.h	Tue Jan 19 12:32:30 2016 +0000
@@ -38,6 +38,14 @@
 
     virtual std::vector<QString> getPluginIdentifiers();
 
+    /**
+     * Return any error message arising from the initial plugin
+     * scan. The return value will either be an empty string (nothing
+     * to report) or an HTML string suitable for dropping into a
+     * dialog and showing the user.
+     */
+    virtual QString getPluginPopulationWarning() { return m_pluginScanError; }
+    
     virtual QString findPluginFile(QString soname, QString inDir = "");
 
     // We don't set blockSize or channels on this -- they're
@@ -59,9 +67,12 @@
     std::map<Vamp::Plugin *, void *> m_handleMap;
     
     std::vector<QString> getPluginCandidateFiles();
-    std::vector<QString> winnowPluginCandidates(std::vector<QString> candidates);
+    std::vector<QString> winnowPluginCandidates(std::vector<QString> candidates,
+                                                QString &warningMessage);
     
     void generateTaxonomy();
+
+    QString m_pluginScanError;
 };
 
 #endif
--- a/system/System.cpp	Mon Jan 11 14:18:56 2016 +0000
+++ b/system/System.cpp	Tue Jan 19 12:32:30 2016 +0000
@@ -358,6 +358,8 @@
             exit(2);
         }
 
+//        cerr << "isPluginLibraryLoadable: Successfully loaded library \"" << soname << "\" and retrieved descriptor function" << endl;
+        
         exit(0);
 
     } else { // the parent process
--- a/transform/TransformFactory.cpp	Mon Jan 11 14:18:56 2016 +0000
+++ b/transform/TransformFactory.cpp	Tue Jan 19 12:32:30 2016 +0000
@@ -399,6 +399,18 @@
     m_transformsPopulated = true;
 }
 
+QString
+TransformFactory::getPluginPopulationWarning()
+{
+    FeatureExtractionPluginFactory *vfactory =
+        FeatureExtractionPluginFactory::instance("vamp");
+    QString warningMessage;
+    if (vfactory) {
+        warningMessage = vfactory->getPluginPopulationWarning();
+    }
+    return warningMessage;
+}
+
 void
 TransformFactory::populateFeatureExtractionPlugins(TransformDescriptionMap &transforms)
 {
--- a/transform/TransformFactory.h	Mon Jan 11 14:18:56 2016 +0000
+++ b/transform/TransformFactory.h	Tue Jan 19 12:32:30 2016 +0000
@@ -196,6 +196,14 @@
     void setParametersFromPluginConfigurationXml(Transform &transform,
                                                  QString xml);
 
+    /**
+     * Return any error message arising from the initial plugin
+     * scan. The return value will either be an empty string (nothing
+     * to report) or an HTML string suitable for dropping into a
+     * dialog and showing the user.
+     */
+    QString getPluginPopulationWarning();
+    
 protected:
     typedef std::map<TransformId, TransformDescription> TransformDescriptionMap;