GNOME Bugzilla – Bug 679271
Completion: fix ref/unref of info window's label
Last modified: 2012-09-17 20:20:08 UTC
The references of the default widget (a GtkLabel) for the CompletionInfo window are not handled correctly.
Created attachment 217861 [details] [review] Completion: fix ref/unref of info window's label There was a memory leak, since the 'default_info' could only be reffed. Also, it is safer to directly ref the widget, so we are sure that any call to gtk_source_completion_info_set_widget() doesn't remove the last reference.
Review of attachment 217861 [details] [review]: I am not so sure about this patch. What about if the info changes every time a proposal is selected?
(In reply to comment #2) > I am not so sure about this patch. What about if the info changes every time a > proposal is selected? The relevant code is in update_proposal_info_real(). gtk_source_completion_provider_get_info_widget() is called, to get the custom info widget for the current proposal (if it returns NULL, the default widget is used). Here is an example: - create the default widget and ref it -> ref_count = 1 - gtk_source_completion_info_set_widget (default_widget) -> ref_count = 2 - choose a proposal with a custom info widget: call gtk_source_completion_info_set_widget (custom_widget) -> the default widget is unreffed, so the ref_count = 1 If the default widget is not initially reffed, a call to set_widget() can finalize it.
I think the patch is right: we keep our ref to the internal widget for the whole lifetime. I pushed the patch