Commit a6c779d8 authored by Caio Tonetti's avatar Caio Tonetti
Browse files

Fix redundant append of rocs/fileformats to library paths

parent 18a77789
...@@ -101,29 +101,27 @@ void FileFormatManager::loadBackends() ...@@ -101,29 +101,27 @@ void FileFormatManager::loadBackends()
} }
d->backends.clear(); d->backends.clear();
// dirs to check for plugins QVector<KPluginMetaData> metadataList = KPluginLoader::findPlugins(
QStringList dirsToCheck; "rocs/fileformats",
foreach (const QString &directory, QCoreApplication::libraryPaths()) { [](const KPluginMetaData &data){
dirsToCheck << directory + QDir::separator() + "rocs/fileformats"; return data.serviceTypes().contains("rocs/graphtheory/fileformat");
} }
);
// load plugins
QPluginLoader loader; QPluginLoader loader;
foreach (const QString &dir, dirsToCheck) {
QVector<KPluginMetaData> metadataList = KPluginLoader::findPlugins(dir,[=](const KPluginMetaData &data){ foreach (const auto &metadata, metadataList) {
return data.serviceTypes().contains("rocs/graphtheory/fileformat");
});
for (const auto &metadata : metadataList) {
loader.setFileName(metadata.fileName()); loader.setFileName(metadata.fileName());
qCDebug(GRAPHTHEORY_FILEFORMAT) << "Load Plugin: " << metadata.name(); qCDebug(GRAPHTHEORY_FILEFORMAT) << "Load Plugin: " << metadata.name();
if (!loader.load()) { if (!loader.load()) {
qCCritical(GRAPHTHEORY_FILEFORMAT) << "Error while loading plugin: " << metadata.name(); qCCritical(GRAPHTHEORY_FILEFORMAT) << "Error while loading plugin: " << metadata.name();
} }
KPluginFactory *factory = KPluginLoader(loader.fileName()).factory(); KPluginFactory *factory = KPluginLoader(loader.fileName()).factory();
FileFormatInterface *plugin = factory->create<FileFormatInterface>(this); FileFormatInterface *plugin = factory->create<FileFormatInterface>(this);
d->backends.append(plugin); d->backends.append(plugin);
} }
}
// display a QMessageBox if no plugins are found // display a QMessageBox if no plugins are found
if (d->backends.empty()) { if (d->backends.empty()) {
...@@ -131,7 +129,7 @@ void FileFormatManager::loadBackends() ...@@ -131,7 +129,7 @@ void FileFormatManager::loadBackends()
pluginErrorMessageBox.setWindowTitle(i18n("Plugin Error")); pluginErrorMessageBox.setWindowTitle(i18n("Plugin Error"));
pluginErrorMessageBox.setTextFormat(Qt::RichText); pluginErrorMessageBox.setTextFormat(Qt::RichText);
pluginErrorMessageBox.setText(i18n("Plugins could not be found in specified directories:<br>")+ pluginErrorMessageBox.setText(i18n("Plugins could not be found in specified directories:<br>")+
dirsToCheck.join("<br>")+ QCoreApplication::libraryPaths().join("/rocs/fileformats<br>")+
i18n("<br><br> Check <a href='https://doc.qt.io/qt-5/deployment-plugins.html'>" i18n("<br><br> Check <a href='https://doc.qt.io/qt-5/deployment-plugins.html'>"
"this link</a> for further information.")); "this link</a> for further information."));
pluginErrorMessageBox.setDefaultButton(QMessageBox::Close); pluginErrorMessageBox.setDefaultButton(QMessageBox::Close);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment