[gupnp-tools/wip/search: 12/12] av-cp: Clean-up SearchDialog on destroy



commit d90e43e486ed466c4075f398c9df7a4c9b86ee8b
Author: Jens Georg <mail jensge org>
Date:   Thu Aug 18 10:37:32 2016 +0200

    av-cp: Clean-up SearchDialog on destroy
    
    Signed-off-by: Jens Georg <mail jensge org>

 src/av-cp/playlist-treeview.c |    1 +
 src/av-cp/search-dialog.c     |   22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/src/av-cp/playlist-treeview.c b/src/av-cp/playlist-treeview.c
index c40912f..e05cd75 100644
--- a/src/av-cp/playlist-treeview.c
+++ b/src/av-cp/playlist-treeview.c
@@ -344,6 +344,7 @@ on_search_menu_item_activated (GtkMenuItem *menuitem,
     search_dialog_set_container_title (SEARCH_DIALOG (search_dialog), title);
 
     gtk_dialog_run (search_dialog);
+    gtk_widget_hide (GTK_WIDGET (search_dialog));
 }
 
 void
diff --git a/src/av-cp/search-dialog.c b/src/av-cp/search-dialog.c
index 18a0b7b..7e69770 100644
--- a/src/av-cp/search-dialog.c
+++ b/src/av-cp/search-dialog.c
@@ -50,6 +50,9 @@ G_DEFINE_TYPE_WITH_PRIVATE (SearchDialog, search_dialog, GTK_TYPE_DIALOG)
 void
 search_dialog_on_search_activate (SearchDialog *self, GtkEntry *entry);
 
+static void
+search_dialog_finalize (GObject *object);
+
 #define ITEM_CLASS_IMAGE "object.item.imageItem"
 #define ITEM_CLASS_AUDIO "object.item.audioItem"
 #define ITEM_CLASS_VIDEO "object.item.videoItem"
@@ -88,6 +91,7 @@ get_item_icon (GUPnPDIDLLiteObject *object)
 static void
 search_dialog_class_init (SearchDialogClass *klass)
 {
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
         GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
         GError *error = NULL;
         gchar *data = NULL;
@@ -112,6 +116,8 @@ search_dialog_class_init (SearchDialogClass *klass)
         gtk_widget_class_bind_template_child_private (widget_class,
                                                       SearchDialog,
                                                       search_dialog_entry);
+
+        object_class->finalize = search_dialog_finalize;
 }
 
 static void
@@ -121,6 +127,22 @@ search_dialog_init (SearchDialog *self)
 }
 
 static void
+search_dialog_finalize (GObject *object)
+{
+        SearchDialog *self = SEARCH_DIALOG (object);
+        SearchDialogPrivate *priv = search_dialog_get_instance_private (self);
+        GObjectClass *parent_class =
+                              G_OBJECT_CLASS (search_dialog_parent_class);
+
+        g_clear_pointer (&priv->id, g_free);
+        g_clear_pointer (&priv->title, g_free);
+
+        if (parent_class->finalize != NULL) {
+                parent_class->finalize (object);
+        }
+}
+
+static void
 on_didl_object_available (GUPnPDIDLLiteParser *parser,
                           GUPnPDIDLLiteObject *object,
                           gpointer             user_data)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]