changeset 1506:a250a54c11cc

Merge from branch avoid-pointer-keys
author Chris Cannam
date Tue, 04 Sep 2018 11:31:35 +0100
parents d7fdc77252c6 (diff) 9d37c8cf9686 (current diff)
children fe579dc6a713 b7cb203ee344
files
diffstat 3 files changed, 109 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/test/svcore-data-fileio-test.cpp	Mon Aug 13 16:45:29 2018 +0100
+++ b/data/fileio/test/svcore-data-fileio-test.cpp	Tue Sep 04 11:31:35 2018 +0100
@@ -35,18 +35,17 @@
 #endif
 
     if (argc > 1) {
-        SVCERR << "argc = " << argc << endl;
         testDir = argv[1];
     }
 
-    if (testDir != "") {
-        SVCERR << "Setting test directory base path to \"" << testDir << "\"" << endl;
-    }
-
     QCoreApplication app(argc, argv);
     app.setOrganizationName("sonic-visualiser");
     app.setApplicationName("test-fileio");
 
+    if (testDir != "") {
+        SVCERR << "Setting test directory base path to \"" << testDir << "\"" << endl;
+    }
+
     {
         AudioFileReaderTest t(testDir);
         if (QTest::qExec(&t, argc, argv) == 0) ++good;
--- a/plugin/PluginScan.cpp	Mon Aug 13 16:45:29 2018 +0100
+++ b/plugin/PluginScan.cpp	Tue Sep 04 11:31:35 2018 +0100
@@ -18,11 +18,7 @@
 #include "base/Preferences.h"
 #include "base/HelperExecPath.h"
 
-#ifdef HAVE_PLUGIN_CHECKER_HELPER
-#include "checker/knownplugincandidates.h"
-#else
-class KnownPluginCandidates {};
-#endif
+#include <sstream>
 
 #include <QMutex>
 #include <QCoreApplication>
@@ -182,6 +178,95 @@
 #endif
 }
 
+#ifdef HAVE_PLUGIN_CHECKER_HELPER
+QString
+PluginScan::formatFailureReport(QString tag,
+                                std::vector<PluginCandidates::FailureRec> failures) const
+{
+    int n = int(failures.size());
+    int i = 0;
+
+    std::ostringstream os;
+    
+    os << "<ul>";
+    for (auto f: failures) {
+        os << "<li>" + f.library;
+
+        SVDEBUG << "PluginScan::formatFailureReport: tag is \"" << tag
+                << "\", failure code is " << int(f.code) << ", message is \""
+                << f.message << "\"" << endl;
+        
+        QString userMessage = QString::fromStdString(f.message);
+
+        switch (f.code) {
+
+        case PluginCheckCode::FAIL_LIBRARY_NOT_FOUND:
+            userMessage = QObject::tr("Library file could not be opened");
+            break;
+
+        case PluginCheckCode::FAIL_WRONG_ARCHITECTURE:
+            if (tag == "64" || (sizeof(void *) == 8 && tag == "")) {
+                userMessage = QObject::tr
+                    ("Library has wrong architecture - possibly a 32-bit plugin installed in a 64-bit plugin folder");
+            } else if (tag == "32" || (sizeof(void *) == 4 && tag == "")) {
+                userMessage = QObject::tr
+                    ("Library has wrong architecture - possibly a 64-bit plugin installed in a 32-bit plugin folder");
+            }
+            break;
+
+        case PluginCheckCode::FAIL_DEPENDENCY_MISSING:
+            userMessage = QObject::tr
+                ("Library depends on another library that cannot be found: %1")
+                .arg(userMessage);
+            break;
+
+        case PluginCheckCode::FAIL_NOT_LOADABLE:
+            userMessage = QObject::tr
+                ("Library cannot be loaded: %1").arg(userMessage);
+            break;
+
+        case PluginCheckCode::FAIL_DESCRIPTOR_MISSING:
+            userMessage = QObject::tr
+                ("Not a valid plugin library (no descriptor found)");
+            break;
+
+        case PluginCheckCode::FAIL_NO_PLUGINS:
+            userMessage = QObject::tr
+                ("Library contains no plugins");
+            break;
+
+        case PluginCheckCode::FAIL_OTHER:
+            if (userMessage == "") {
+                userMessage = QObject::tr
+                    ("Unknown error");
+            }
+            break;
+
+        case PluginCheckCode::SUCCESS:
+            // success shouldn't happen here!
+            break;
+        }
+        
+        os << "<br><i>" + userMessage.toStdString() + "</i>";
+        os << "</li>";
+
+        if (n > 10) {
+            if (++i == 5) {
+                os << "<li>";
+                os << QObject::tr("... and %n further failure(s)",
+                                  "", n - i)
+                    .toStdString();
+                os << "</li>";
+                break;
+            }
+        }
+    }
+    os << "</ul>";
+
+    return QString::fromStdString(os.str());
+}
+#endif
+
 QString
 PluginScan::getStartupFailureReport() const
 {
@@ -204,7 +289,10 @@
 
     QString report;
     for (auto kp: m_kp) {
-        report += QString::fromStdString(kp.second->getFailureReport());
+        auto failures = kp.second->getFailures();
+        if (!failures.empty()) {
+            report += formatFailureReport(kp.first, failures);
+        }
     }
     if (report == "") {
         return report;
--- a/plugin/PluginScan.h	Mon Aug 13 16:45:29 2018 +0100
+++ b/plugin/PluginScan.h	Tue Sep 04 11:31:35 2018 +0100
@@ -20,7 +20,11 @@
 #include <vector>
 #include <map>
 
-class KnownPluginCandidates;
+#ifdef HAVE_PLUGIN_CHECKER_HELPER
+#include "checker/knownplugincandidates.h"
+#else
+class KnownPluginCandidates {};
+#endif
 
 class PluginScan
 {
@@ -73,6 +77,12 @@
 
     void clear();
 
+#ifdef HAVE_PLUGIN_CHECKER_HELPER
+    QString formatFailureReport(QString helperTag,
+                                std::vector<PluginCandidates::FailureRec>)
+        const;
+#endif
+
     mutable QMutex m_mutex; // while scanning; definitely can't multi-thread this
     
     std::map<QString, KnownPluginCandidates *> m_kp; // tag -> KnownPlugins client