From 1c8f24269e817f88b5b5f5cea6d7e1484c3c4862 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Fri, 23 Aug 2019 11:41:20 +0200 Subject: [PATCH] Prevent plugins from being loaded multiple times --- .../devices/devicemanagerimplementation.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libnymea-core/devices/devicemanagerimplementation.cpp b/libnymea-core/devices/devicemanagerimplementation.cpp index e9c5e9c0..3ad199ee 100644 --- a/libnymea-core/devices/devicemanagerimplementation.cpp +++ b/libnymea-core/devices/devicemanagerimplementation.cpp @@ -173,9 +173,10 @@ QStringList DeviceManagerImplementation::pluginSearchDirs() foreach (QString libraryPath, QCoreApplication::libraryPaths()) { searchDirs << libraryPath.replace("qt5", "nymea"); } - searchDirs << QCoreApplication::applicationDirPath() + "/../lib/nymea/plugins"; - searchDirs << QCoreApplication::applicationDirPath() + "/../plugins/"; - searchDirs << QCoreApplication::applicationDirPath() + "/../../../plugins/"; + searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../lib/nymea/plugins").absolutePath(); + searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../plugins/").absolutePath(); + searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../../../plugins/").absolutePath(); + searchDirs.removeDuplicates(); return searchDirs; } @@ -883,6 +884,10 @@ void DeviceManagerImplementation::loadPlugins() loader.unload(); continue; } + if (m_devicePlugins.contains(pluginIface->pluginId())) { + qCWarning(dcDeviceManager()) << "A plugin with this ID is already loaded. Not loading" << entry; + continue; + } loadPlugin(pluginIface, metaData); } } @@ -1307,7 +1312,7 @@ void DeviceManagerImplementation::slotPairingFinished(const PairingTransactionId case Device::DeviceSetupStatusAsync: return; case Device::DeviceSetupStatusSuccess: - qCDebug(dcDeviceManager) << "Device setup complete."; + qCDebug(dcDeviceManager) << "Paired Device setup complete."; break; } @@ -1376,7 +1381,7 @@ void DeviceManagerImplementation::onAutoDevicesAppeared(const DeviceClassId &dev case Device::DeviceSetupStatusAsync: break; case Device::DeviceSetupStatusSuccess: - qCDebug(dcDeviceManager) << "Device setup complete."; + qCDebug(dcDeviceManager) << "Auto Device setup complete."; m_configuredDevices.insert(device->id(), device); storeConfiguredDevices(); emit deviceSetupFinished(device, Device::DeviceErrorNoError);