comparison plugin/PluginScan.cpp @ 1249:d45a16c232bd piper

Align Sonic Annotator with the new Piper-ified subrepos (bearing in mind we want neither Piper nor the plugin load checker in Sonic Annotator itself)
author Chris Cannam
date Fri, 04 Nov 2016 14:16:01 +0000
parents 8f076d02569a
children a99641535e02
comparison
equal deleted inserted replaced
1248:58dd6a6fe414 1249:d45a16c232bd
16 16
17 #include "base/Debug.h" 17 #include "base/Debug.h"
18 #include "base/Preferences.h" 18 #include "base/Preferences.h"
19 #include "base/HelperExecPath.h" 19 #include "base/HelperExecPath.h"
20 20
21 #ifdef HAVE_PLUGIN_CHECKER_HELPER
21 #include "checker/knownplugins.h" 22 #include "checker/knownplugins.h"
23 #else
24 class KnownPlugins {};
25 #endif
22 26
23 #include <QMutex> 27 #include <QMutex>
24 #include <QCoreApplication> 28 #include <QCoreApplication>
25 29
26 using std::string; 30 using std::string;
27 31
28 class PluginScan::Logger : public PluginCandidates::LogCallback 32 class PluginScan::Logger
33 #ifdef HAVE_PLUGIN_CHECKER_HELPER
34 : public PluginCandidates::LogCallback
35 #endif
29 { 36 {
30 protected: 37 protected:
31 void log(std::string message) { 38 void log(std::string message) {
32 SVDEBUG << "PluginScan: " << message; 39 SVDEBUG << "PluginScan: " << message;
33 } 40 }
53 } 60 }
54 61
55 void 62 void
56 PluginScan::scan() 63 PluginScan::scan()
57 { 64 {
65 #ifdef HAVE_PLUGIN_CHECKER_HELPER
66
58 QMutexLocker locker(&m_mutex); 67 QMutexLocker locker(&m_mutex);
59 68
60 bool inProcess = Preferences::getInstance()->getRunPluginsInProcess(); 69 bool inProcess = Preferences::getInstance()->getRunPluginsInProcess();
61 70
62 HelperExecPath hep(inProcess ? 71 HelperExecPath hep(inProcess ?
94 } catch (const std::exception &e) { 103 } catch (const std::exception &e) {
95 SVDEBUG << "ERROR: PluginScan::scan: " << e.what() 104 SVDEBUG << "ERROR: PluginScan::scan: " << e.what()
96 << " (with helper path = " << p.executable << ")" << endl; 105 << " (with helper path = " << p.executable << ")" << endl;
97 } 106 }
98 } 107 }
108
109 #endif
99 } 110 }
100 111
101 bool 112 bool
102 PluginScan::scanSucceeded() const 113 PluginScan::scanSucceeded() const
103 { 114 {
116 } 127 }
117 128
118 QList<PluginScan::Candidate> 129 QList<PluginScan::Candidate>
119 PluginScan::getCandidateLibrariesFor(PluginType type) const 130 PluginScan::getCandidateLibrariesFor(PluginType type) const
120 { 131 {
132 #ifdef HAVE_PLUGIN_CHECKER_HELPER
133
121 QMutexLocker locker(&m_mutex); 134 QMutexLocker locker(&m_mutex);
122 135
123 KnownPlugins::PluginType kpt; 136 KnownPlugins::PluginType kpt;
124 switch (type) { 137 switch (type) {
125 case VampPlugin: kpt = KnownPlugins::VampPlugin; break; 138 case VampPlugin: kpt = KnownPlugins::VampPlugin; break;
155 break; 168 break;
156 } 169 }
157 } 170 }
158 171
159 return candidates; 172 return candidates;
173
174 #else
175 return {};
176 #endif
160 } 177 }
161 178
162 QString 179 QString
163 PluginScan::getStartupFailureReport() const 180 PluginScan::getStartupFailureReport() const
164 { 181 {
182 #ifdef HAVE_PLUGIN_CHECKER_HELPER
183
165 QMutexLocker locker(&m_mutex); 184 QMutexLocker locker(&m_mutex);
166 185
167 if (!m_succeeded) { 186 if (!m_succeeded) {
168 return QObject::tr("<b>Failed to scan for plugins</b>" 187 return QObject::tr("<b>Failed to scan for plugins</b>"
169 "<p>Failed to scan for plugins at startup. Possibly " 188 "<p>Failed to scan for plugins at startup. Possibly "
189 "<p>Failed to load one or more plugin libraries:</p>") 208 "<p>Failed to load one or more plugin libraries:</p>")
190 + report 209 + report
191 + QObject::tr("<p>These plugins may be incompatible with the system, " 210 + QObject::tr("<p>These plugins may be incompatible with the system, "
192 "and will be ignored during this run of %1.</p>") 211 "and will be ignored during this run of %1.</p>")
193 .arg(QCoreApplication::applicationName()); 212 .arg(QCoreApplication::applicationName());
194 } 213
195 214 #else
215 return "";
216 #endif
217 }
218