fix a crash if we get an update for a rule we don't know
This commit is contained in:
parent
10e8453094
commit
7ac9b012d6
@ -99,14 +99,8 @@ void RuleManager::handleRulesNotification(const QVariantMap ¶ms)
|
|||||||
} else if (params.value("notification").toString() == "Rules.RuleConfigurationChanged") {
|
} else if (params.value("notification").toString() == "Rules.RuleConfigurationChanged") {
|
||||||
QVariantMap ruleMap = params.value("params").toMap().value("rule").toMap();
|
QVariantMap ruleMap = params.value("params").toMap().value("rule").toMap();
|
||||||
QUuid ruleId = ruleMap.value("id").toUuid();
|
QUuid ruleId = ruleMap.value("id").toUuid();
|
||||||
int idx = -1;
|
Rule *rule = m_rules->getRule(ruleId);
|
||||||
for (int i = 0; i < m_rules->rowCount(); i++) {
|
if (!rule) {
|
||||||
if (m_rules->get(i)->id() == ruleId) {
|
|
||||||
idx = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (idx == -1) {
|
|
||||||
qWarning() << "Got a rule update notification for a rule we don't know" << ruleId;
|
qWarning() << "Got a rule update notification for a rule we don't know" << ruleId;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -114,7 +108,7 @@ void RuleManager::handleRulesNotification(const QVariantMap ¶ms)
|
|||||||
m_rules->insert(parseRule(ruleMap));
|
m_rules->insert(parseRule(ruleMap));
|
||||||
} else if (params.value("notification").toString() == "Rules.RuleActiveChanged") {
|
} else if (params.value("notification").toString() == "Rules.RuleActiveChanged") {
|
||||||
Rule *rule = m_rules->getRule(params.value("params").toMap().value("ruleId").toUuid());
|
Rule *rule = m_rules->getRule(params.value("params").toMap().value("ruleId").toUuid());
|
||||||
if (rule) {
|
if (!rule) {
|
||||||
qWarning() << "Got a rule active notification for a rule we don't know";
|
qWarning() << "Got a rule active notification for a rule we don't know";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user