[gnome-builder] editor: track number of view instances



commit 2d3cc868c0ba0f6a393a1734d9bf11d8c1257252
Author: Christian Hergert <chergert redhat com>
Date:   Sat Jul 1 14:04:27 2017 -0700

    editor: track number of view instances
    
    There is a leak somewhere here, and this can help us track it
    down.

 libide/editor/ide-editor-view.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/libide/editor/ide-editor-view.c b/libide/editor/ide-editor-view.c
index 0a60797..770bd3e 100644
--- a/libide/editor/ide-editor-view.c
+++ b/libide/editor/ide-editor-view.c
@@ -49,6 +49,8 @@ static void ide_editor_view_update_reveal_timer (IdeEditorView *self);
 
 G_DEFINE_TYPE (IdeEditorView, ide_editor_view, IDE_TYPE_LAYOUT_VIEW)
 
+DZL_DEFINE_COUNTER (instances, "Editor", "N Views", "Number of editor views");
+
 static GParamSpec *properties [N_PROPS];
 static FcConfig *localFontConfig;
 
@@ -433,6 +435,14 @@ ide_editor_view_destroy (GtkWidget *widget)
 }
 
 static void
+ide_editor_view_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (ide_editor_view_parent_class)->finalize (object);
+
+  DZL_COUNTER_DEC (instances);
+}
+
+static void
 ide_editor_view_get_property (GObject    *object,
                               guint       prop_id,
                               GValue     *value,
@@ -497,6 +507,7 @@ ide_editor_view_class_init (IdeEditorViewClass *klass)
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
   IdeLayoutViewClass *layout_view_class = IDE_LAYOUT_VIEW_CLASS (klass);
 
+  object_class->finalize = ide_editor_view_finalize;
   object_class->constructed = ide_editor_view_constructed;
   object_class->get_property = ide_editor_view_get_property;
   object_class->set_property = ide_editor_view_set_property;
@@ -557,6 +568,8 @@ ide_editor_view_init (IdeEditorView *self)
 {
   GtkTargetList *target_list;
 
+  DZL_COUNTER_INC (instances);
+
   gtk_widget_init_template (GTK_WIDGET (self));
 
   ide_layout_view_set_can_split (IDE_LAYOUT_VIEW (self), TRUE);


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