From a915f48fd9672cc003be717c62b3445cbd4c63e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Wed, 22 Nov 2023 10:37:13 +0100 Subject: [PATCH] fix(StatusQ): check if role exists in ModelUtils::contains Without the check, asking for not existing role led to segfault. --- ui/StatusQ/src/modelutilsinternal.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/StatusQ/src/modelutilsinternal.cpp b/ui/StatusQ/src/modelutilsinternal.cpp index d6e313d28b..00fd20a566 100644 --- a/ui/StatusQ/src/modelutilsinternal.cpp +++ b/ui/StatusQ/src/modelutilsinternal.cpp @@ -95,7 +95,13 @@ bool ModelUtilsInternal::contains(QAbstractItemModel* model, Qt::MatchFlags flags = Qt::MatchFixedString; // Qt::CaseInsensitive by default 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(); }