genlist: clear 'rel' pointer when it becomes unused during del_pre_hook.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Thu, 28 Nov 2013 22:42:16 +0000 (20:42 -0200)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Thu, 28 Nov 2013 22:42:16 +0000 (20:42 -0200)
commit085e644c49a4aebacb2e2952aff717bf281bab45
treea992683583dc5281eff4331eeabf4cf32a0f8711
parent877abee7fe618968697a2092aaf8a2dc6487bc7b
genlist: clear 'rel' pointer when it becomes unused during del_pre_hook.

If we're walking an item and it's deleted, the memory won't go away
immediately in _item_del_pre_hook() as would in _item_del(), then it's
not enough to remove ourselves from the reverse-relative list of the
item we were relative to, we also need to clean our own relative
pointer so we won't touch it later when the item is not being walked
anymore and _item_del() is called.

I was getting this annoying error with espionage application, opening
an interface of an object and then closing the window or selecting
another bus name (whatever would call elm_genlist_clear()).

During the clear process genlist will flag the next item as "walking"
so it's not gone when the current item dies (would happen if next item
is a subitem). The item would run _item_del_pre_hook() but not
_item_del(), but on the next loop iteration the next item would be the
current, then not walking anymore and during _item_del() it would
access it->item->rel which would point to the now-dead item.
legacy/elementary/src/lib/elm_genlist.c