most entries are not kcms, fail gracefully

don't spit scary errors when an entry has an empty plugin path,
ie not a kcm

Change-Id: I1f2cc744aaed315ae3dd56d5a55082eb09a5ed6e
This commit is contained in:
Marco Martin 2015-05-26 15:44:41 +02:00
parent 1fcdc08222
commit cc97bd8297

View File

@ -210,11 +210,17 @@ QVariant ConfigModel::data(const QModelIndex &index, int role) const
return d->categories.at(index.row())->visible();
case KCMRole: {
const QString pluginName = d->categories.at(index.row())->pluginName();
const QString pluginPath = KPluginLoader::findPlugin(pluginName);
//no kcm is registered for this row, it's a normal qml-only entry
if (pluginName.isEmpty() || pluginPath.isEmpty()) {
return QVariant();
}
if (d->kcms.contains(pluginName)) {
return QVariant::fromValue(d->kcms.value(pluginName));
}
KPluginLoader loader(KPluginLoader::findPlugin(pluginName));
KPluginLoader loader(pluginPath);
KPluginFactory* factory = loader.factory();
if (!factory) {
qWarning() << "Error loading KCM:" << loader.errorString();