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 774352 - GtkAppChooserWidget does not unref all GAppInfo it references
GtkAppChooserWidget does not unref all GAppInfo it references
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkAppChooser
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
Cosimo Cecchi
Depends on:
Blocks:
 
 
Reported: 2016-11-13 09:27 UTC by Massimo
Modified: 2016-11-14 19:21 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Massimo 2016-11-13 09:27:39 UTC
After setting GOBJECT_DEBUG=objects comparing the outputs
of the following program run with ITERATIONS set to 2 and 1:

#include <gtk/gtk.h>

#ifndef ITERATIONS
#define ITERATIONS 2
#endif

int
main (int   argc, 
      char *argv[])
{
  if (gtk_init_check (&argc, &argv))                    
    {
      for (gint i = 0; i < ITERATIONS; ++i)             
        {
          GtkWidget *dialog = gtk_app_chooser_dialog_new_for_content_type (NULL, 0, "text/plain");

          gtk_widget_show (dialog);                     

          gtk_widget_destroy (dialog);                  
        }
    }

  return 0;
}


the number of objects alive at exit increases for the presence
of many (it depends on the number of suitable apps on the system)
GDesktopAppInfo objects referenced by GtkAppChooserWidget.

The problem is here:

https://git.gnome.org/browse/gtk+/tree/gtk/gtkappchooserwidget.c?h=gtk-3-22#n154

gtk_tree_model_get increments info's ref_count and this reference
is transferred to self->priv->selected_app_info in the two cases
where info is assigned to it, but it is not removed when
g_app_info_equal returns FALSE.