Models: fix two potential crashes
CylinderModels::setDive() and WeightModel::setDive() have potential to pass the 'last' argument to beginInsertRows() as a negative number which triggers an assert that 'last' cannot be smaller than 'first'. Patch attempts to fix that by only calling beginInsertRows() when there is at least one row to insert. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d23266ad51
commit
a2a93ff04b
@ -323,12 +323,13 @@ void CylindersModel::setDive(dive* d)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
beginInsertRows(QModelIndex(), 0, amount-1);
|
||||
rows = amount;
|
||||
current = d;
|
||||
changed = false;
|
||||
endInsertRows();
|
||||
if (amount > 0) {
|
||||
beginInsertRows(QModelIndex(), 0, amount - 1);
|
||||
endInsertRows();
|
||||
}
|
||||
}
|
||||
|
||||
Qt::ItemFlags CylindersModel::flags(const QModelIndex& index) const
|
||||
@ -504,12 +505,13 @@ void WeightModel::setDive(dive* d)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
beginInsertRows(QModelIndex(), 0, amount-1);
|
||||
rows = amount;
|
||||
current = d;
|
||||
changed = false;
|
||||
endInsertRows();
|
||||
if (amount > 0) {
|
||||
beginInsertRows(QModelIndex(), 0, amount - 1);
|
||||
endInsertRows();
|
||||
}
|
||||
}
|
||||
|
||||
WSInfoModel* WSInfoModel::instance()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user