[rhythmbox] grilo: simplify cleanup and remove sources from the grilo registry too



commit 34dc7691dc95c7ac0e88c29abf5242729decca28
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sun Dec 11 16:21:05 2016 +1000

    grilo: simplify cleanup and remove sources from the grilo registry too
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770486

 plugins/grilo/rb-grilo-plugin.c |   38 +++++++++++---------------------------
 1 files changed, 11 insertions(+), 27 deletions(-)
---
diff --git a/plugins/grilo/rb-grilo-plugin.c b/plugins/grilo/rb-grilo-plugin.c
index 5b9287d..6f2f2b6 100644
--- a/plugins/grilo/rb-grilo-plugin.c
+++ b/plugins/grilo/rb-grilo-plugin.c
@@ -92,16 +92,6 @@ rb_grilo_plugin_init (RBGriloPlugin *plugin)
 }
 
 static void
-rb_grilo_plugin_source_deleted (RBGriloSource *source, RBGriloPlugin *plugin)
-{
-       GrlSource *grilo_source;
-
-       g_object_get (source, "media-source", &grilo_source, NULL);
-       g_hash_table_remove (plugin->sources, grilo_source);
-       g_object_unref (grilo_source);
-}
-
-static void
 grilo_source_added_cb (GrlRegistry *registry, GrlSource *grilo_source, RBGriloPlugin *plugin)
 {
        GrlPlugin *grilo_plugin;
@@ -232,28 +222,22 @@ impl_activate (PeasActivatable *plugin)
 }
 
 static void
-_delete_cb (GrlSource *grilo_source,
-           RBSource *source,
-           RBGriloPlugin *plugin)
-{
-       /* block the source deleted handler so we don't modify the hash table
-        * while iterating it.
-        */
-       g_signal_handlers_block_by_func (source, rb_grilo_plugin_source_deleted, plugin);
-       rb_display_page_delete_thyself (RB_DISPLAY_PAGE (source));
-}
-
-static void
 impl_deactivate        (PeasActivatable *bplugin)
 {
-       RBGriloPlugin         *plugin = RB_GRILO_PLUGIN (bplugin);
-
-       g_hash_table_foreach (plugin->sources, (GHFunc)_delete_cb, plugin);
-       g_hash_table_destroy (plugin->sources);
-       plugin->sources = NULL;
+       RBGriloPlugin *plugin = RB_GRILO_PLUGIN (bplugin);
+       GHashTableIter iter;
+       gpointer key, value;
 
        g_signal_handler_disconnect (plugin->registry, plugin->handler_id_source_added);
        g_signal_handler_disconnect (plugin->registry, plugin->handler_id_source_removed);
+
+       g_hash_table_iter_init (&iter, plugin->sources);
+       while (g_hash_table_iter_next (&iter, &key, &value)) {
+               grl_registry_unregister_source (plugin->registry, GRL_SOURCE (key), NULL);
+               rb_display_page_delete_thyself (RB_DISPLAY_PAGE (value));
+       }
+       g_hash_table_destroy (plugin->sources);
+       plugin->sources = NULL;
        plugin->registry = NULL;
 
        if (plugin->emit_cover_art_id != 0) {


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