diff options
author | Dominik Holland <dominik.holland@pelagicore.com> | 2018-04-27 10:07:55 +0200 |
---|---|---|
committer | Dominik Holland <dominik.holland@pelagicore.com> | 2018-05-03 12:26:00 +0000 |
commit | 6e95e95bce698ad1844099c5bc4b5822e56ecb06 (patch) | |
tree | 4fccf816d3d68e7d29577fdda46867d6b4419680 /src/ivicore | |
parent | c2a46c9363e2ef5cf6e5ef2372f07570118369e5 (diff) | |
download | qtivi-6e95e95bce698ad1844099c5bc4b5822e56ecb06.tar.gz |
Only load every plugin once
We use the canonicalFilePath as identifier to check whether the plugin
is already in the list.
Task-number: AUTOSUITE-289
Change-Id: I42965495f29237fbd20cfdde1611a56dabcff441
Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
Diffstat (limited to 'src/ivicore')
-rw-r--r-- | src/ivicore/qiviservicemanager.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/ivicore/qiviservicemanager.cpp b/src/ivicore/qiviservicemanager.cpp index 6b7d859..ff6af67 100644 --- a/src/ivicore/qiviservicemanager.cpp +++ b/src/ivicore/qiviservicemanager.cpp @@ -162,21 +162,22 @@ void QIviServiceManagerPrivate::searchPlugins() const auto pluginDirs = QCoreApplication::libraryPaths(); for (const QString &pluginDir : pluginDirs) { - QDir dir(pluginDir); QString path = pluginDir + QDir::separator() + QLatin1String(QIVI_PLUGIN_DIRECTORY); + QDir dir(path); //Check whether the directory exists - if (!QDir(path).exists(QStringLiteral("."))) + if (!dir.exists()) continue; const QStringList plugins = QDir(path).entryList(QDir::Files); - for (const QString &pluginPath : plugins) { - if (!QLibrary::isLibrary(pluginPath)) + for (const QString &pluginFileName : plugins) { + if (!QLibrary::isLibrary(pluginFileName)) continue; - const QString fileName = QDir::cleanPath(path + QLatin1Char('/') + pluginPath); - const QString absFileName = dir.absoluteFilePath(fileName); - QPluginLoader loader(absFileName); - registerBackend(loader.fileName(), loader.metaData()); + const QFileInfo info(dir, pluginFileName); + const QString absFile = info.canonicalFilePath(); + QPluginLoader loader(absFile); + + registerBackend(absFile, loader.metaData()); found = true; } } |