After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 679271 - Completion: fix ref/unref of info window's label
Completion: fix ref/unref of info window's label
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: General
unspecified
Other All
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2012-07-02 17:49 UTC by Sébastien Wilmet
Modified: 2012-09-17 20:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Completion: fix ref/unref of info window's label (1.79 KB, patch)
2012-07-02 17:49 UTC, Sébastien Wilmet
none Details | Review

Description Sébastien Wilmet 2012-07-02 17:49:53 UTC
The references of the default widget (a GtkLabel) for the CompletionInfo window are not handled correctly.
Comment 1 Sébastien Wilmet 2012-07-02 17:49:55 UTC
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.
Comment 2 Ignacio Casal Quinteiro (nacho) 2012-07-02 17:55:41 UTC
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?
Comment 3 Sébastien Wilmet 2012-07-02 19:00:55 UTC
(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.
Comment 4 Paolo Borelli 2012-09-17 20:20:08 UTC
I think the patch is right: we keep our ref to the internal widget for the whole lifetime.

I pushed the patch