diff options
author | Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at> | 2021-02-07 16:21:29 +0100 |
---|---|---|
committer | Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at> | 2021-02-07 16:21:29 +0100 |
commit | 3933124de456ca15221fc6a8ffbeb1ebd7c6ee84 (patch) | |
tree | 72370cd9752b7fe4d5b0180e9372ade046d83443 /libxfce4ui/xfce-titled-dialog.c | |
parent | 9fc6c9669f6e1167a80a201afbf1baacfc129215 (diff) | |
download | libxfce4ui-3933124de456ca15221fc6a8ffbeb1ebd7c6ee84.tar.gz |
Don't leak pixbuf
Diffstat (limited to 'libxfce4ui/xfce-titled-dialog.c')
-rw-r--r-- | libxfce4ui/xfce-titled-dialog.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libxfce4ui/xfce-titled-dialog.c b/libxfce4ui/xfce-titled-dialog.c index bdc98f2..995c072 100644 --- a/libxfce4ui/xfce-titled-dialog.c +++ b/libxfce4ui/xfce-titled-dialog.c @@ -78,6 +78,7 @@ struct _XfceTitledDialogPrivate GtkWidget *headerbar; GtkWidget *icon; GtkWidget *action_area; + GdkPixbuf *pixbuf; gchar *subtitle; }; @@ -170,6 +171,7 @@ xfce_titled_dialog_init (XfceTitledDialog *titled_dialog) gtk_header_bar_pack_start (GTK_HEADER_BAR (titled_dialog->priv->headerbar), titled_dialog->priv->icon); gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (titled_dialog->priv->headerbar), TRUE); gtk_widget_show (titled_dialog->priv->icon); + titled_dialog->priv->pixbuf = NULL; /* make sure to update the icon whenever one of the relevant window properties changes */ g_signal_connect (G_OBJECT (titled_dialog), "notify::icon", G_CALLBACK (xfce_titled_dialog_update_icon), NULL); @@ -186,6 +188,9 @@ xfce_titled_dialog_finalize (GObject *object) /* release the subtitle */ g_free (titled_dialog->priv->subtitle); + /* release the pixbuf */ + g_object_unref (titled_dialog->priv->pixbuf); + (*G_OBJECT_CLASS (xfce_titled_dialog_parent_class)->finalize) (object); } @@ -268,10 +273,10 @@ xfce_titled_dialog_update_icon (XfceTitledDialog *titled_dialog) } else { - GdkPixbuf *pixbuf; - pixbuf = gtk_window_get_icon (GTK_WINDOW (titled_dialog)); - if (pixbuf) - gtk_image_set_from_pixbuf (GTK_IMAGE (titled_dialog->priv->icon), pixbuf); + if (titled_dialog->priv->pixbuf) + g_object_unref (titled_dialog->priv->pixbuf); + titled_dialog->priv->pixbuf = gtk_window_get_icon (GTK_WINDOW (titled_dialog)); + gtk_image_set_from_pixbuf (GTK_IMAGE (titled_dialog->priv->icon), titled_dialog->priv->pixbuf); } } |