From b9c427a316e61b13344f7d8a069e31c96b04dd26 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 8 Sep 2015 17:57:55 +0200 Subject: [PATCH] fix crash and simplify code reviewed by Albert Vaca --- kcm/kcm.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index f457e05cc..9495be79e 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -215,21 +215,21 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current) connect(currentDevice,SIGNAL(pairingFailed(QString)), this, SLOT(pairingFailed(QString))); - QList pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins("kdeconnect/")); + const QList pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins("kdeconnect/")); + QList availablePluginInfo; QList missingPluginInfo; QStringList missingPluginNames = currentDevice->unsupportedPlugins(); - for (auto it = pluginInfo.begin(), itEnd = pluginInfo.end(); it!=itEnd; ) { + for (auto it = pluginInfo.cbegin(), itEnd = pluginInfo.cend(); it!=itEnd; ++it) { if (missingPluginNames.contains(it->pluginName())) { missingPluginInfo.append(*it); - it = pluginInfo.erase(it); } else { - ++it; + availablePluginInfo.append(*it); } } KSharedConfigPtr deviceConfig = KSharedConfig::openConfig(currentDevice->pluginsConfigFile()); - kcmUi->pluginSelector->addPlugins(pluginInfo, KPluginSelector::ReadConfigFile, i18n("Available plugins"), QString(), deviceConfig); + kcmUi->pluginSelector->addPlugins(availablePluginInfo, KPluginSelector::ReadConfigFile, i18n("Available plugins"), QString(), deviceConfig); kcmUi->pluginSelector->addPlugins(missingPluginInfo, KPluginSelector::ReadConfigFile, i18n("Plugins unsupported by the device"), QString(), deviceConfig); connect(kcmUi->pluginSelector, SIGNAL(changed(bool)),