[gnome-builder] editor: don't use weak callback for tracking view



commit 961d2ed90cf833c8b64559af47aed8cfdac90763
Author: Christian Hergert <chergert redhat com>
Date:   Thu Oct 27 22:50:44 2016 -0700

    editor: don't use weak callback for tracking view
    
    It is not safe to do this here because we want to use the object after
    the view has been finalized. But we can use GtkWidget::destroy for the
    same thing.

 libide/editor/ide-editor-perspective.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/libide/editor/ide-editor-perspective.c b/libide/editor/ide-editor-perspective.c
index fba5b20..fca0207 100644
--- a/libide/editor/ide-editor-perspective.c
+++ b/libide/editor/ide-editor-perspective.c
@@ -302,9 +302,12 @@ ide_editor_perspective_finalize (GObject *object)
 }
 
 static void
-ide_editor_perspective_view_weak_cb (IdeEditorPerspective *self,
-                                     IdeLayoutView        *view)
+ide_editor_perspective_view_destroyed (IdeEditorPerspective *self,
+                                       IdeLayoutView        *view)
 {
+  g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
+  g_assert (IDE_IS_EDITOR_VIEW (view));
+
   g_signal_emit (self, signals [VIEW_REMOVED], 0, view);
 }
 
@@ -323,10 +326,11 @@ ide_editor_perspective_add (GtkContainer *container,
 
       last_focus = ide_layout_grid_get_last_focus (self->grid);
       gtk_container_add (GTK_CONTAINER (last_focus), widget);
-      g_object_weak_ref (G_OBJECT (widget),
-                         (GWeakNotify)ide_editor_perspective_view_weak_cb,
-                         container);
-
+      g_signal_connect_object (widget,
+                               "destroy",
+                               G_CALLBACK (ide_editor_perspective_view_destroyed),
+                               self,
+                               G_CONNECT_SWAPPED);
       g_signal_emit (self, signals [VIEW_ADDED], 0, widget);
       return;
     }


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