mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-16 16:47:24 +00:00
fix(general): added check if role passed to ModelUtils.get exists
This commit is contained in:
parent
453d75b304
commit
6d7a018aaf
@ -3,6 +3,7 @@
|
|||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
ModelUtilsInternal::ModelUtilsInternal(QObject* parent)
|
ModelUtilsInternal::ModelUtilsInternal(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
@ -45,7 +46,10 @@ QVariantMap ModelUtilsInternal::get(QAbstractItemModel *model, int row) const
|
|||||||
QVariant ModelUtilsInternal::get(QAbstractItemModel *model,
|
QVariant ModelUtilsInternal::get(QAbstractItemModel *model,
|
||||||
int row, const QString &roleName) const
|
int row, const QString &roleName) const
|
||||||
{
|
{
|
||||||
return model->data(model->index(row, 0), roleByName(model, roleName));
|
if (auto role = roleByName(model, roleName); role != -1)
|
||||||
|
return model->data(model->index(row, 0), roleByName(model, roleName));
|
||||||
|
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModelUtilsInternal::contains(QAbstractItemModel* model,
|
bool ModelUtilsInternal::contains(QAbstractItemModel* model,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user