mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
CylindersModel: don't crash if accessing non-existing cylinder
It shouldn't happen, but currently we overwrite the displayed_dive without updating the CylindersModel. Thus, CylindersModel may now crash when the new displayed_dive has less cylinders than the old one. For now, catch this condition. Treat the root cause later. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
906cce9e88
commit
62b869b24a
1 changed files with 5 additions and 0 deletions
|
@ -134,6 +134,11 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
|
|||
if (!index.isValid() || index.row() >= rows)
|
||||
return QVariant();
|
||||
|
||||
if (index.row() >= displayed_dive.cylinders.nr) {
|
||||
qWarning("CylindersModel and displayed_dive are out of sync!");
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
const cylinder_t *cyl = get_cylinder(&displayed_dive, index.row());
|
||||
|
||||
switch (role) {
|
||||
|
|
Loading…
Add table
Reference in a new issue