[gnome-photos/wip/rishi/misc-fixes: 4/9] Sprinkle some counters to keep track of object count



commit b9c46106a87f0e992e7313d1fedd2a8ad767c78f
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Dec 15 14:51:43 2015 +0100

    Sprinkle some counters to keep track of object count

 src/photos-base-item.c            |    6 ++++++
 src/photos-item-manager.c         |    6 ++++++
 src/photos-offset-controller.c    |   17 +++++++++++++++++
 src/photos-pipeline.c             |    6 ++++++
 src/photos-selection-controller.c |    9 +++++++++
 src/photos-tracker-controller.c   |    9 +++++++++
 6 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index a93f5ae..fa5bb64 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -37,6 +37,7 @@
 #include <libgd/gd.h>
 #include <tracker-sparql.h>
 
+#include "egg-counter.h"
 #include "photos-application.h"
 #include "photos-base-item.h"
 #include "photos-collection-icon-watcher.h"
@@ -124,6 +125,7 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (PhotosBaseItem, photos_base_item, G_TYPE_OBJEC
                                   G_ADD_PRIVATE (PhotosBaseItem)
                                   G_IMPLEMENT_INTERFACE (PHOTOS_TYPE_FILTERABLE,
                                                          photos_base_item_filterable_iface_init));
+EGG_DEFINE_COUNTER (instances, "PhotosBaseItem", "Instances", "Number of PhotosBaseItem instances");
 
 
 typedef struct _PhotosBaseItemSaveData PhotosBaseItemSaveData;
@@ -1396,6 +1398,8 @@ photos_base_item_finalize (GObject *object)
   g_mutex_clear (&priv->mutex);
 
   G_OBJECT_CLASS (photos_base_item_parent_class)->finalize (object);
+
+  EGG_COUNTER_DEC (instances);
 }
 
 
@@ -1445,6 +1449,8 @@ photos_base_item_init (PhotosBaseItem *self)
 {
   PhotosBaseItemPrivate *priv;
 
+  EGG_COUNTER_INC (instances);
+
   self->priv = photos_base_item_get_instance_private (self);
   priv = self->priv;
 
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index b13c9bf..4f4010a 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -29,6 +29,7 @@
 #include <glib.h>
 #include <tracker-sparql.h>
 
+#include "egg-counter.h"
 #include "photos-enums.h"
 #include "photos-filterable.h"
 #include "photos-item-manager.h"
@@ -85,6 +86,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
 
 
 G_DEFINE_TYPE (PhotosItemManager, photos_item_manager, PHOTOS_TYPE_BASE_MANAGER);
+EGG_DEFINE_COUNTER (instances, "PhotosItemManager", "Instances", "Number of PhotosItemManager instances");
 
 
 static void
@@ -435,12 +437,16 @@ photos_item_manager_finalize (GObject *object)
   g_queue_free (self->history);
 
   G_OBJECT_CLASS (photos_item_manager_parent_class)->finalize (object);
+
+  EGG_COUNTER_DEC (instances);
 }
 
 
 static void
 photos_item_manager_init (PhotosItemManager *self)
 {
+  EGG_COUNTER_INC (instances);
+
   self->collections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
   self->extension_point = g_io_extension_point_lookup (PHOTOS_BASE_ITEM_EXTENSION_POINT_NAME);
   self->collection_path = g_queue_new ();
diff --git a/src/photos-offset-controller.c b/src/photos-offset-controller.c
index f84cbfd..33f1772 100644
--- a/src/photos-offset-controller.c
+++ b/src/photos-offset-controller.c
@@ -28,6 +28,7 @@
 #include <glib.h>
 #include <tracker-sparql.h>
 
+#include "egg-counter.h"
 #include "photos-offset-controller.h"
 #include "photos-query-builder.h"
 #include "photos-tracker-queue.h"
@@ -51,6 +52,10 @@ static guint signals[LAST_SIGNAL] = { 0 };
 
 
 G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (PhotosOffsetController, photos_offset_controller, G_TYPE_OBJECT);
+EGG_DEFINE_COUNTER (instances,
+                    "PhotosOffsetController",
+                    "Instances",
+                    "Number of PhotosOffsetController instances");
 
 
 enum
@@ -112,10 +117,21 @@ photos_offset_controller_dispose (GObject *object)
 
 
 static void
+photos_offset_controller_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (photos_offset_controller_parent_class)->finalize (object);
+
+  EGG_COUNTER_DEC (instances);
+}
+
+
+static void
 photos_offset_controller_init (PhotosOffsetController *self)
 {
   PhotosOffsetControllerPrivate *priv;
 
+  EGG_COUNTER_INC (instances);
+
   self->priv = photos_offset_controller_get_instance_private (self);
   priv = self->priv;
 
@@ -129,6 +145,7 @@ photos_offset_controller_class_init (PhotosOffsetControllerClass *class)
   GObjectClass *object_class = G_OBJECT_CLASS (class);
 
   object_class->dispose = photos_offset_controller_dispose;
+  object_class->finalize = photos_offset_controller_finalize;
 
   signals[COUNT_CHANGED] = g_signal_new ("count-changed",
                                          G_TYPE_FROM_CLASS (class),
diff --git a/src/photos-pipeline.c b/src/photos-pipeline.c
index b1f9688..604a861 100644
--- a/src/photos-pipeline.c
+++ b/src/photos-pipeline.c
@@ -25,6 +25,7 @@
 
 #include <glib.h>
 
+#include "egg-counter.h"
 #include "photos-debug.h"
 #include "photos-operation-insta-common.h"
 #include "photos-pipeline.h"
@@ -58,6 +59,7 @@ static void photos_pipeline_async_initable_iface_init (GAsyncInitableIface *ifac
 
 G_DEFINE_TYPE_EXTENDED (PhotosPipeline, photos_pipeline, G_TYPE_OBJECT, 0,
                         G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, 
photos_pipeline_async_initable_iface_init));
+EGG_DEFINE_COUNTER (instances, "PhotosPipeline", "Instances", "Number of PhotosPipeline instances");
 
 
 static gchar *
@@ -159,6 +161,8 @@ photos_pipeline_finalize (GObject *object)
   g_free (self->uri);
 
   G_OBJECT_CLASS (photos_pipeline_parent_class)->finalize (object);
+
+  EGG_COUNTER_DEC (instances);
 }
 
 
@@ -187,6 +191,8 @@ photos_pipeline_set_property (GObject *object, guint prop_id, const GValue *valu
 static void
 photos_pipeline_init (PhotosPipeline *self)
 {
+  EGG_COUNTER_INC (instances);
+
   self->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
   self->history = g_queue_new ();
 }
diff --git a/src/photos-selection-controller.c b/src/photos-selection-controller.c
index 449a842..404fb01 100644
--- a/src/photos-selection-controller.c
+++ b/src/photos-selection-controller.c
@@ -28,6 +28,7 @@
 #include <gio/gio.h>
 #include <glib.h>
 
+#include "egg-counter.h"
 #include "photos-base-manager.h"
 #include "photos-filterable.h"
 #include "photos-search-context.h"
@@ -53,6 +54,10 @@ static guint signals[LAST_SIGNAL] = { 0 };
 
 
 G_DEFINE_TYPE_WITH_PRIVATE (PhotosSelectionController, photos_selection_controller, G_TYPE_OBJECT);
+EGG_DEFINE_COUNTER (instances,
+                    "PhotosSelectionController",
+                    "Instances",
+                    "Number of PhotosSelectionController instances");
 
 
 static void
@@ -112,6 +117,8 @@ photos_selection_controller_finalize (GObject *object)
     g_object_remove_weak_pointer (G_OBJECT (priv->item_mngr), (gpointer *) &priv->item_mngr);
 
   G_OBJECT_CLASS (photos_selection_controller_parent_class)->finalize (object);
+
+  EGG_COUNTER_DEC (instances);
 }
 
 
@@ -122,6 +129,8 @@ photos_selection_controller_init (PhotosSelectionController *self)
   GApplication *app;
   PhotosSearchContextState *state;
 
+  EGG_COUNTER_INC (instances);
+
   self->priv = photos_selection_controller_get_instance_private (self);
   priv = self->priv;
 
diff --git a/src/photos-tracker-controller.c b/src/photos-tracker-controller.c
index 0666143..7d7bfce 100644
--- a/src/photos-tracker-controller.c
+++ b/src/photos-tracker-controller.c
@@ -30,6 +30,7 @@
 
 #include <gio/gio.h>
 
+#include "egg-counter.h"
 #include "photos-base-manager.h"
 #include "photos-debug.h"
 #include "photos-enums.h"
@@ -79,6 +80,10 @@ static guint signals[LAST_SIGNAL] = { 0 };
 
 
 G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (PhotosTrackerController, photos_tracker_controller, G_TYPE_OBJECT);
+EGG_DEFINE_COUNTER (instances,
+                    "PhotosTrackerController",
+                    "Instances",
+                    "Number of PhotosTrackerController instances");
 
 
 typedef enum
@@ -365,6 +370,8 @@ photos_tracker_controller_finalize (GObject *object)
     photos_query_free (priv->current_query);
 
   G_OBJECT_CLASS (photos_tracker_controller_parent_class)->finalize (object);
+
+  EGG_COUNTER_DEC (instances);
 }
 
 
@@ -393,6 +400,8 @@ photos_tracker_controller_init (PhotosTrackerController *self)
   GApplication *app;
   PhotosSearchContextState *state;
 
+  EGG_COUNTER_INC (instances);
+
   self->priv = photos_tracker_controller_get_instance_private (self);
   priv = self->priv;
 


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