[PATCH] broadband-modem-mbim: explicitly remove notification handler on unref

Aleksander Morgado aleksander at aleksander.es
Fri Aug 11 18:11:29 UTC 2017


>> When we remove the last object reference, make sure the notification
>> handler is also removed, or we may end up using an already freed
>> object.
>>
>> https://retrace.fedoraproject.org/faf/reports/1815001/
>
> Good catch; any time we connect a signal somewhere in an object, we
> should probably have an explicit disconnect/clear of that handler in
> the finalize/dispose path just to be sure.
>
> Which brings up the question, should that kind of thing go in dispose?
> Honestly I don't think it makes much of a difference, except that if
> it's in finalize we might get the handler triggered during dispose when
> half the object is cleaned up already.
>

I'm not sure there's any convention regarding one or the other; truth
be told. I've usually used dispose() only to cleanup GObjects, as
g_object_run_dispose() may be used to cleanup circular references, and
finalize() for everything else.

-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list