Mercurial > hg > svcore
diff plugin/PluginScan.cpp @ 1242:c401e738793f piper
Merge from branch 3.0-integration
author | Chris Cannam |
---|---|
date | Tue, 01 Nov 2016 14:08:57 +0000 |
parents | c6bdf247016a |
children | 0492e54ccd56 |
line wrap: on
line diff
--- a/plugin/PluginScan.cpp Fri Oct 28 15:19:12 2016 +0100 +++ b/plugin/PluginScan.cpp Tue Nov 01 14:08:57 2016 +0000 @@ -15,6 +15,7 @@ #include "PluginScan.h" #include "base/Debug.h" +#include "base/HelperExecPath.h" #include "checker/knownplugins.h" @@ -50,22 +51,36 @@ } PluginScan::~PluginScan() { - delete m_kp; + clear(); delete m_logger; } void -PluginScan::scan(QString helperExecutablePath) +PluginScan::scan() { - delete m_kp; + QStringList helperPaths = + HelperExecPath::getHelperExecutables("plugin-checker-helper"); + + clear(); + + for (auto p: helperPaths) { + try { + KnownPlugins *kp = new KnownPlugins(p.toStdString(), m_logger); + m_kp.push_back(kp); + m_succeeded = true; + } catch (const std::exception &e) { + cerr << "ERROR: PluginScan::scan: " << e.what() + << " (with helper path = " << p << ")" << endl; + } + } +} + +void +PluginScan::clear() +{ + for (auto &p: m_kp) delete p; + m_kp.clear(); m_succeeded = false; - try { - m_kp = new KnownPlugins(helperExecutablePath.toStdString(), m_logger); - m_succeeded = true; - } catch (const std::exception &e) { - cerr << "ERROR: PluginScan::scan: " << e.what() << endl; - m_kp = 0; - } } QStringList @@ -80,9 +95,10 @@ } QStringList candidates; - if (!m_kp) return candidates; - auto c = m_kp->getCandidateLibrariesFor(kpt); - for (auto s: c) candidates.push_back(s.c_str()); + for (auto kp: m_kp) { + auto c = kp->getCandidateLibrariesFor(kpt); + for (auto s: c) candidates.push_back(s.c_str()); + } return candidates; } @@ -96,20 +112,23 @@ "installed alongside %1?</p>") .arg(QCoreApplication::applicationName()); } - if (!m_kp) { + if (m_kp.empty()) { return QObject::tr("<b>Did not scan for plugins</b>" "<p>Apparently no scan for plugins was attempted " "(internal error?)</p>"); } - string report = m_kp->getFailureReport(); + QString report; + for (auto kp: m_kp) { + report += QString::fromStdString(kp->getFailureReport()); + } if (report == "") { - return QString(report.c_str()); + return report; } return QObject::tr("<b>Failed to load plugins</b>" "<p>Failed to load one or more plugin libraries:</p>") - + QString(report.c_str()) + + report + QObject::tr("<p>These plugins may be incompatible with the system, " "and will be ignored during this run of %1.</p>") .arg(QCoreApplication::applicationName());