From e73553088b825cfec0cafbe77ec4a338bb75f55e Mon Sep 17 00:00:00 2001
From: Julian Bouzas <julian.bouzas@collabora.com>
Date: Wed, 26 Jun 2019 12:48:09 -0400
Subject: [PATCH] proxy: remove unneeded destroy signal

---
 lib/wp/core.c                 | 3 ++-
 lib/wp/proxy.c                | 8 --------
 lib/wp/proxy.h                | 1 -
 modules/module-pipewire.c     | 4 ++--
 modules/module-pw-alsa-udev.c | 4 ++--
 5 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/lib/wp/core.c b/lib/wp/core.c
index 34984c2b..5d9c24f4 100644
--- a/lib/wp/core.c
+++ b/lib/wp/core.c
@@ -60,7 +60,8 @@ wp_core_dispose (GObject * obj)
 
   /* Remove and emit the removed signal for all globals */
   while (global_objects->len > 0) {
-    global = g_ptr_array_steal_index_fast (global_objects, 0);
+    global = g_ptr_array_steal_index_fast (global_objects,
+        global_objects->len - 1);
     g_signal_emit (self, signals[SIGNAL_GLOBAL_REMOVED], global->key,
         global->key, global->object);
     free_global_object (global);
diff --git a/lib/wp/proxy.c b/lib/wp/proxy.c
index 8d9917b4..54622d13 100644
--- a/lib/wp/proxy.c
+++ b/lib/wp/proxy.c
@@ -34,7 +34,6 @@ enum {
 
 enum
 {
-  SIGNAL_DESTROYED,
   SIGNAL_DONE,
   LAST_SIGNAL,
 };
@@ -54,9 +53,6 @@ proxy_event_destroy (void *data)
 
   /* Set the proxy to NULL */
   self->proxy = NULL;
-
-  /* Emit the destroy signal */
-  g_signal_emit (data, wp_proxy_signals[SIGNAL_DESTROYED], 0);
 }
 
 static void
@@ -198,10 +194,6 @@ wp_proxy_class_init (WpProxyClass * klass)
       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
 
   /* Signals */
-  wp_proxy_signals[SIGNAL_DESTROYED] =
-    g_signal_new ("destroyed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
-    G_STRUCT_OFFSET (WpProxyClass, destroyed), NULL, NULL, NULL, G_TYPE_NONE,
-    0);
   wp_proxy_signals[SIGNAL_DONE] =
     g_signal_new ("done", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
     G_STRUCT_OFFSET (WpProxyClass, done), NULL, NULL, NULL, G_TYPE_NONE, 0);
diff --git a/lib/wp/proxy.h b/lib/wp/proxy.h
index be3570b4..5dab6a80 100644
--- a/lib/wp/proxy.h
+++ b/lib/wp/proxy.h
@@ -24,7 +24,6 @@ struct _WpProxyClass
   GObjectClass parent_class;
 
   /* Signals */
-  void (*destroyed)(WpProxy *wp_proxy, gpointer data);
   void (*done)(WpProxy *wp_proxy, gpointer data);
 };
 
diff --git a/modules/module-pipewire.c b/modules/module-pipewire.c
index 7a58def4..9394b1e6 100644
--- a/modules/module-pipewire.c
+++ b/modules/module-pipewire.c
@@ -105,9 +105,9 @@ on_global_removed (WpRemotePipewire *rp, guint id, gpointer d)
   if (!endpoint)
     return;
 
-  /* Remove the endpoint from the table and unregister it */
-  g_hash_table_remove (data->registered_endpoints, GUINT_TO_POINTER(id));
+  /* Unregister the endpoint and remove it from the table */
   wp_endpoint_unregister (endpoint);
+  g_hash_table_remove (data->registered_endpoints, GUINT_TO_POINTER(id));
 }
 
 static void
diff --git a/modules/module-pw-alsa-udev.c b/modules/module-pw-alsa-udev.c
index dd652f3e..74c34979 100644
--- a/modules/module-pw-alsa-udev.c
+++ b/modules/module-pw-alsa-udev.c
@@ -92,9 +92,9 @@ on_global_removed (WpRemotePipewire *rp, guint id, gpointer d)
   if (!endpoint)
     return;
 
-  /* Remove the endpoint from the table and unregister it */
-  g_hash_table_remove (impl->registered_endpoints, GUINT_TO_POINTER(id));
+  /* Unregister the endpoint and remove it from the table */
   wp_endpoint_unregister (endpoint);
+  g_hash_table_remove (impl->registered_endpoints, GUINT_TO_POINTER(id));
 }
 
 static void
-- 
GitLab