fix: don't call sourceData with an invalid role

This is related to bug #46
This commit is contained in:
Grecko 2018-03-22 23:36:59 +01:00
parent 6ff055d47d
commit 9c3e57c02e
1 changed files with 4 additions and 0 deletions

View File

@ -154,6 +154,10 @@ QPair<QVariant, QVariant> RoleSorter::sourceData(const QModelIndex &sourceLeft,
{
QPair<QVariant, QVariant> pair;
int role = proxyModel.roleForName(m_roleName);
if (role == -1)
return pair;
pair.first = proxyModel.sourceData(sourceLeft, role);
pair.second = proxyModel.sourceData(sourceRight, role);
return pair;