mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Don't allow the event handler list to shrink while we're traversing it.
This change isn't ideal in the sense that the handler list is now a monotonically increasing resource, but it's better than crashing when the handler in node N+1 happens to be deleted while servicing the handler in node N. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13152 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
124ef42e61
commit
943532c8cd
@ -108,15 +108,19 @@ gnc_engine_unregister_event_handler (gint handler_id)
|
||||
if (hi->handler_id != handler_id)
|
||||
continue;
|
||||
|
||||
/* Found it, take out of list */
|
||||
handlers = g_list_remove_link (handlers, node);
|
||||
/* Normally, we could actually remove the handler's node from the
|
||||
list, but we may be unregistering the event handler as a result
|
||||
of a generated event, such as GNC_EVENT_DESTROY. In that case,
|
||||
we're in the middle of walking the GList and it is wrong to
|
||||
modify the list. So, instead, we just NULL the handler. */
|
||||
/* handlers = g_list_remove_link (handlers, node); */
|
||||
|
||||
LEAVE ("(handler_id=%d) handler=%p data=%p", handler_id, hi->handler, hi->user_data);
|
||||
/* safety */
|
||||
hi->handler = NULL;
|
||||
|
||||
g_list_free_1 (node);
|
||||
g_free (hi);
|
||||
/* g_list_free_1 (node);
|
||||
g_free (hi); */
|
||||
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user