[gnome-photos] query: Check whether the active source is NULL or not



commit 6e47d95e4ba524e797669faedc1b1462ac4dbcf2
Author: Debarshi Ray <debarshir gnome org>
Date:   Sat May 5 21:40:57 2012 +0200

    query: Check whether the active source is NULL or not

 src/photos-query.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-query.c b/src/photos-query.c
index 898d9b0..5fda04b 100644
--- a/src/photos-query.c
+++ b/src/photos-query.c
@@ -29,12 +29,15 @@ PhotosQuery *
 photos_query_new (gchar *sparql)
 {
   PhotosBaseManager *src_mngr;
+  GObject *active_object;
   PhotosQuery *query;
 
   query = g_slice_new0 (PhotosQuery);
 
   src_mngr = photos_source_manager_new ();
-  query->source = PHOTOS_SOURCE (photos_base_manager_get_active_object (src_mngr));
+  active_object = photos_base_manager_get_active_object (src_mngr);
+  if (active_object != NULL)
+    query->source = PHOTOS_SOURCE (active_object);
   g_object_unref (src_mngr);
 
   query->sparql = sparql;
@@ -46,7 +49,8 @@ photos_query_new (gchar *sparql)
 void
 photos_query_free (PhotosQuery *query)
 {
-  g_object_unref (query->source);
+  if (query->source != NULL)
+    g_object_unref (query->source);
   g_free (query->sparql);
   g_slice_free (PhotosQuery, query);
 }



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