Cancel or remove pending internal asynchronous operations or sources during destruction
Submitted by Debarshi Ray
We cancel (g_cancellable_cancel) or remove (g_source_remove) pending internal asynchronous operations or sources when an object is destroyed.
Right now, we hold a reference to the object itself (g_object_ref (self)) to delay the destruction while something is pending. This approach is easier to implement, but has a few drawbacks:
(a) Code outside such objects (ie. their clients) are not expecting them to stay alive after they have dropped all their references. Therefore, if the pending asynchronous operation or source has any visible side-effects (eg., emitting a signal) then bad things can happen (eg., crashes).
(b) All objects might not be destroyed during shutdown. This is usually not a big issue because the process is about to die anyway. In our case, though, gegl_exit complains if some GeglBuffers were still alive.
(c) Not cancelling or removing pending items is a bit wasteful.
I have a few patches to get this started.
Feel free to pick it up. Just make sure that you split it into smaller patches (eg., one for object or operation/source) so that it is easier to review and test against regressions.