GNOME Bugzilla – Bug 707339
gutterrenderer: use sourceview after destroy
Last modified: 2013-10-27 16:23:14 UTC
When using multiple sourceviews to view a single buffer, destroying one of the sourceviews can cause the lines gutterrenderer to use view after it has been destroyed.
Created attachment 253917 [details] [review] renderegutterrendererlines: use g_signal_connect_object() Fixes a bug where on_buffer_changed() is called after view has been disposed.
Review of attachment 253917 [details] [review]: hystoricall g_signal_connect_object() was documented as a "broken" function that didn't do what it was supposed to do... is it fixed these days? [1] Also, the handler_id is not set to 0 in this case... is this a problem? [1] https://developer.gnome.org/gobject/2.30/gobject-Signals.html#g-signal-connect-object contains a note that's removed in the current docs.
(In reply to comment #2) > Review of attachment 253917 [details] [review]: > > hystoricall g_signal_connect_object() was documented as a "broken" function > that didn't do what it was supposed to do... is it fixed these days? [1] I'm not sure on that, but it did fix my problem. > Also, the handler_id is not set to 0 in this case... is this a problem? Yes, when using multiple gtksourceview sharing the same buffer, I would hit this after destroying the second widget. Alternatively, we can just make sure we disconnect them instead of connect_object.
Yes, I think we should use a weak_ref or a weak_pointer and disconnect ourselves and clear the handler
g_signal_connect_object() works as it is documented now. So I think it has been fixed.
Review of attachment 253917 [details] [review]: For me the commit is good. It is not a problem that priv->changed_handler_id is not set to 0, because when the signal handler is disconnected automatically, the gutter renderer is disposed.
Review of attachment 253917 [details] [review]: Well, if the buffer change between the dispose and finalize, there is a problem. Why not simply disconnect the signal handler in dispose? we have the changed_handler_id and the current buffer anyway.
Fixed: https://git.gnome.org/browse/gtksourceview/commit/?id=c0901ddea05b93ca09804ec701ca57c873420e0c