fix crash and simplify code

reviewed by Albert Vaca
This commit is contained in:
Aleix Pol 2015-09-08 17:57:55 +02:00
parent 6a379e9227
commit b9c427a316

View file

@ -215,21 +215,21 @@ void KdeConnectKcm::deviceSelected(const QModelIndex& current)
connect(currentDevice,SIGNAL(pairingFailed(QString)),
this, SLOT(pairingFailed(QString)));
QList<KPluginInfo> pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins("kdeconnect/"));
const QList<KPluginInfo> pluginInfo = KPluginInfo::fromMetaData(KPluginLoader::findPlugins("kdeconnect/"));
QList<KPluginInfo> availablePluginInfo;
QList<KPluginInfo> 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)),