[libshumate] marker-layer: Use g_signal_connect_object() to connect to markers



commit c012f31ce52ea5293c8395e0ea9465adfa3f98a5
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Mar 10 12:27:06 2021 -0300

    marker-layer: Use g_signal_connect_object() to connect to markers
    
    There's no guarantee that markers will be destroyed together with the marker
    layer. In fact, applications can reuse markers through the already available
    ShumateMarkerLayer API.
    
    Avoid a potentially crashy callback by using g_signal_connect_object(), which
    disconnects the signal automatically when the marker layer is destroyed.

 shumate/shumate-marker-layer.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/shumate/shumate-marker-layer.c b/shumate/shumate-marker-layer.c
index f0ce9cb..e966844 100644
--- a/shumate/shumate-marker-layer.c
+++ b/shumate/shumate-marker-layer.c
@@ -444,10 +444,10 @@ shumate_marker_layer_add_marker (ShumateMarkerLayer *layer,
 
   shumate_marker_set_selectable (marker, priv->mode != GTK_SELECTION_NONE);
 
-  g_signal_connect (G_OBJECT (marker), "notify::latitude",
-      G_CALLBACK (marker_position_notify), layer);
-  g_signal_connect (G_OBJECT (marker), "notify::longitude",
-      G_CALLBACK (marker_position_notify), layer);
+  g_signal_connect_object (G_OBJECT (marker), "notify::latitude",
+      G_CALLBACK (marker_position_notify), layer, 0);
+  g_signal_connect_object (G_OBJECT (marker), "notify::longitude",
+      G_CALLBACK (marker_position_notify), layer, 0);
 
   /*g_signal_connect (G_OBJECT (marker), "drag-motion",
       G_CALLBACK (marker_move_by_cb), layer);*/


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