mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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
1 changed files with 8 additions and 6 deletions
|
@ -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…
Add table
Reference in a new issue