fix(StatusQ): check if role exists in ModelUtils::contains
Without the check, asking for not existing role led to segfault.
This commit is contained in:
parent
24f2540ffa
commit
a915f48fd9
|
@ -95,7 +95,13 @@ bool ModelUtilsInternal::contains(QAbstractItemModel* model,
|
||||||
|
|
||||||
Qt::MatchFlags flags = Qt::MatchFixedString; // Qt::CaseInsensitive by default
|
Qt::MatchFlags flags = Qt::MatchFixedString; // Qt::CaseInsensitive by default
|
||||||
if(mode == Qt::CaseSensitive) flags |= Qt::MatchCaseSensitive;
|
if(mode == Qt::CaseSensitive) flags |= Qt::MatchCaseSensitive;
|
||||||
const auto indexes = model->match(model->index(0, 0), roleByName(model, roleName), value, 1, flags);
|
|
||||||
|
auto role = roleByName(model, roleName);
|
||||||
|
|
||||||
|
if (role == -1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const auto indexes = model->match(model->index(0, 0), role, value, 1, flags);
|
||||||
return !indexes.isEmpty();
|
return !indexes.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue