Mercurial > hg > svcore
comparison plugin/FeatureExtractionPluginFactory.cpp @ 1166:4607603c46d0
Show warning to the user when plugin population has problems
author | Chris Cannam |
---|---|
date | Tue, 19 Jan 2016 12:32:30 +0000 |
parents | d57f9344db19 |
children | 7c4f4701b49f |
comparison
equal
deleted
inserted
replaced
1165:d57f9344db19 | 1166:4607603c46d0 |
---|---|
134 | 134 |
135 return candidates; | 135 return candidates; |
136 } | 136 } |
137 | 137 |
138 vector<QString> | 138 vector<QString> |
139 FeatureExtractionPluginFactory::winnowPluginCandidates(vector<QString> candidates) | 139 FeatureExtractionPluginFactory::winnowPluginCandidates(vector<QString> candidates, |
140 QString &warningMessage) | |
140 { | 141 { |
141 vector<QString> good, bad; | 142 vector<QString> good, bad; |
142 vector<PluginLoadStatus> badStatuses; | 143 vector<PluginLoadStatus> badStatuses; |
143 | 144 |
144 for (QString c: candidates) { | 145 for (QString c: candidates) { |
157 badStatuses.push_back(status); | 158 badStatuses.push_back(status); |
158 } | 159 } |
159 } | 160 } |
160 | 161 |
161 if (!bad.empty()) { | 162 if (!bad.empty()) { |
162 QString warningMessage = "<b>Failed to load plugins</b></p>Failed to load one or more plugin libraries:</p><ul>\n"; | 163 warningMessage = |
164 QObject::tr("<b>Failed to load plugins</b>" | |
165 "<p>Failed to load one or more plugin libraries:</p>\n"); | |
166 warningMessage += "<ul>"; | |
163 for (int i = 0; i < bad.size(); ++i) { | 167 for (int i = 0; i < bad.size(); ++i) { |
164 QString m; | 168 QString m; |
165 if (badStatuses[i] == PluginLoadFailedToLoadLibrary) { | 169 if (badStatuses[i] == PluginLoadFailedToLoadLibrary) { |
166 m = "Failed to load library"; | 170 m = QObject::tr("Failed to load library"); |
167 } else if (badStatuses[i] == PluginLoadFailedToFindDescriptor) { | 171 } else if (badStatuses[i] == PluginLoadFailedToFindDescriptor) { |
168 m = "Failed to query plugins from library after loading"; | 172 m = QObject::tr("Failed to query plugins from library after loading"); |
169 } else if (badStatuses[i] == PluginLoadFailedElsewhere) { | 173 } else if (badStatuses[i] == PluginLoadFailedElsewhere) { |
170 m = "Unknown failure"; | 174 m = QObject::tr("Unknown failure"); |
171 } else { | 175 } else { |
172 m = "Success: internal error?"; | 176 m = QObject::tr("Success: internal error?"); |
173 } | 177 } |
174 warningMessage += QString("<li>%1 (%2)</li>\n") | 178 warningMessage += QString("<li>%1 (%2)</li>\n") |
175 .arg(bad[i]) | 179 .arg(bad[i]) |
176 .arg(m); | 180 .arg(m); |
177 } | 181 } |
178 warningMessage += "</ul>"; | 182 warningMessage += "</ul>"; |
179 cerr << warningMessage; //!!! for now! | |
180 } | 183 } |
181 return good; | 184 return good; |
182 } | 185 } |
183 | 186 |
184 vector<QString> | 187 vector<QString> |
185 FeatureExtractionPluginFactory::getPluginIdentifiers() | 188 FeatureExtractionPluginFactory::getPluginIdentifiers() |
186 { | 189 { |
187 Profiler profiler("FeatureExtractionPluginFactory::getPluginIdentifiers"); | 190 Profiler profiler("FeatureExtractionPluginFactory::getPluginIdentifiers"); |
188 | 191 |
189 vector<QString> rv; | 192 vector<QString> rv; |
190 vector<QString> candidates = winnowPluginCandidates(getPluginCandidateFiles()); | 193 vector<QString> candidates = winnowPluginCandidates(getPluginCandidateFiles(), |
194 m_pluginScanError); | |
191 | 195 |
192 for (QString soname : candidates) { | 196 for (QString soname : candidates) { |
193 | 197 |
194 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE | 198 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE |
195 SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname << endl; | 199 SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname << endl; |
234 << soname | 238 << soname |
235 << " returns the same plugin identifier \"" | 239 << " returns the same plugin identifier \"" |
236 << descriptor->identifier << "\" at indices " | 240 << descriptor->identifier << "\" at indices " |
237 << known[descriptor->identifier] << " and " | 241 << known[descriptor->identifier] << " and " |
238 << index << endl; | 242 << index << endl; |
239 SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl; | 243 cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl; |
240 ok = false; | 244 ok = false; |
241 break; | 245 break; |
242 } else { | 246 } else { |
243 known[descriptor->identifier] = index; | 247 known[descriptor->identifier] = index; |
244 } | 248 } |