[gnome-photos/wip/rishi/misc-fixes: 12/18] offset-collections-controller: Break a reference cycle
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/misc-fixes: 12/18] offset-collections-controller: Break a reference cycle
- Date: Mon, 14 Dec 2015 19:18:09 +0000 (UTC)
commit beffa89d79c94baa508c2df85fe7fe292e194198
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Dec 14 19:19:01 2015 +0100
offset-collections-controller: Break a reference cycle
src/photos-offset-collections-controller.c | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/src/photos-offset-collections-controller.c b/src/photos-offset-collections-controller.c
index 69e63c3..c8f502f 100644
--- a/src/photos-offset-collections-controller.c
+++ b/src/photos-offset-collections-controller.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2013, 2014 Red Hat, Inc.
+ * Copyright © 2013, 2014, 2015 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -48,17 +48,20 @@ static PhotosQuery *
photos_offset_collections_controller_get_query (PhotosOffsetController *offset_cntrlr)
{
PhotosOffsetCollectionsController *self = PHOTOS_OFFSET_COLLECTIONS_CONTROLLER (offset_cntrlr);
+ PhotosOffsetCollectionsControllerPrivate *priv = self->priv;
GApplication *app;
PhotosBaseItem *collection;
PhotosSearchContextState *state;
- gint flags;
+ gint flags = PHOTOS_QUERY_FLAGS_COLLECTIONS;
- collection = photos_item_manager_get_active_collection (PHOTOS_ITEM_MANAGER (self->priv->item_mngr));
+ if (priv->item_mngr == NULL)
+ goto end;
+
+ collection = photos_item_manager_get_active_collection (PHOTOS_ITEM_MANAGER (priv->item_mngr));
if (collection != NULL)
flags = PHOTOS_QUERY_FLAGS_NONE;
- else
- flags = PHOTOS_QUERY_FLAGS_COLLECTIONS;
+ end:
app = g_application_get_default ();
state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
@@ -87,13 +90,15 @@ photos_offset_collections_controller_constructor (GType type,
static void
-photos_offset_collections_controller_dispose (GObject *object)
+photos_offset_collections_controller_finalize (GObject *object)
{
PhotosOffsetCollectionsController *self = PHOTOS_OFFSET_COLLECTIONS_CONTROLLER (object);
+ PhotosOffsetCollectionsControllerPrivate *priv = self->priv;
- g_clear_object (&self->priv->item_mngr);
+ if (priv->item_mngr != NULL)
+ g_object_remove_weak_pointer (G_OBJECT (priv->item_mngr), (gpointer *) &priv->item_mngr);
- G_OBJECT_CLASS (photos_offset_collections_controller_parent_class)->dispose (object);
+ G_OBJECT_CLASS (photos_offset_collections_controller_parent_class)->finalize (object);
}
@@ -110,7 +115,8 @@ photos_offset_collections_controller_init (PhotosOffsetCollectionsController *se
app = g_application_get_default ();
state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
- priv->item_mngr = g_object_ref (state->item_mngr);
+ priv->item_mngr = state->item_mngr;
+ g_object_add_weak_pointer (G_OBJECT (priv->item_mngr), (gpointer *) &priv->item_mngr);
}
@@ -121,7 +127,7 @@ photos_offset_collections_controller_class_init (PhotosOffsetCollectionsControll
PhotosOffsetControllerClass *offset_controller_class = PHOTOS_OFFSET_CONTROLLER_CLASS (class);
object_class->constructor = photos_offset_collections_controller_constructor;
- object_class->dispose = photos_offset_collections_controller_dispose;
+ object_class->finalize = photos_offset_collections_controller_finalize;
offset_controller_class->get_query = photos_offset_collections_controller_get_query;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]