Program Crash on dive delete

Dirk Hohndel dirk at hohndel.org
Sat Oct 19 08:28:04 UTC 2013


I have been distracted by real life from Subsurface and will be on a plane without Internet for most of today and have personal matters that will distract me further Sunday and Monday… please don't let this stop anyone from sending patches, but understand that I may not be very responsive the next few days.

On Oct 19, 2013, at 2:15 AM, Lubomir I. Ivanov wrote:

> On 19 October 2013 08:26, Willem Ferguson
> <willemferguson at zoology.up.ac.za> wrote:
>> My version of subsurface crashes when deleting dives in a particular way.
>> Here is a dataset :
>> https://www.dropbox.com/s/zi5l9ez0s9laf9y/test1.xml
>> 
>> Delete the top 6 dives by deleting the dive at the top of the list each
>> time.
>> Then delete dive number 4 (dated Sat Jul 6th)
>> Program crashes.
> 
> attached is a temporary patch that fixes this.
> 
> here is a BT:
> #0  0x0041b5cf in DiveListView::selectDive (this=0x22fc92c8, dive=0x0,
>    scrollto=true, toggle=false) at qt-ui/divelistview.cpp:69
> #1  0x0041bc9e in DiveListView::reload (this=0x22fc92c8,
>    layout=DiveTripModel::TREE, forceSort=true) at qt-ui/divelistview.cpp:168
> #2  0x004387c3 in MainWindow::refreshDisplay (this=0x22a015b0)
>    at qt-ui/mainwindow.cpp:70
> #3  0x0041d277 in DiveListView::deleteDive (this=0x22fc92c8)
>    at qt-ui/divelistview.cpp:371
> #4  0x00469c0a in DiveListView::qt_static_metacall (_o=0x22fc92c8,
>    _c=QMetaObject::InvokeMetaMethod, _id=6, _a=0x289d08)
>    at .moc/moc_divelistview.cpp:75
> 
> divelistview.cpp: 169
> if (amount_selected && selected_dive >= 0) {
> selectDive(current_dive, true);
> 
> what happens here after willem's sequence of commands is that
> selected_dive is 8, amount_selected is 1
> but current_dive is NULL. so i think there should be a better fix,
> perhaps in DiveListView::deleteDive().

I haven't looked at this AT ALL - but selected_dive = 8 and current_dive = NULL can only happen if we have eight or fewer dives left. current_dive is just a macro that does get_dive(selected_dive) - and that will only return NULL if selected_dive <0 or >= dive_table.nr

So there are two issues here
a) why is selected_dive = 8? That should be investigated
b) add a check around the access of current_dive that makes sure that isn't NULL

/D



More information about the subsurface mailing list