[gnome-photos/wip/rishi/view-model: 5/6] item-manager: Be more strict about what is acceptable



commit 72e1e2d217a6ddc87c6c11cf6bcdec96442c7c21
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Aug 24 11:08:04 2016 +0200

    item-manager: Be more strict about what is acceptable

 src/photos-item-manager.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-item-manager.c b/src/photos-item-manager.c
index 6634888..39d726c 100644
--- a/src/photos-item-manager.c
+++ b/src/photos-item-manager.c
@@ -708,6 +708,9 @@ photos_item_manager_activate_previous_collection (PhotosItemManager *self)
 void
 photos_item_manager_add_item (PhotosItemManager *self, TrackerSparqlCursor *cursor, gboolean force)
 {
+  g_return_if_fail (PHOTOS_IS_ITEM_MANAGER (self));
+  g_return_if_fail (TRACKER_SPARQL_IS_CURSOR (cursor));
+
   if (photos_item_manager_cursor_is_collection (cursor))
     {
       if (self->active_collection != NULL && force)
@@ -731,12 +734,19 @@ photos_item_manager_add_item_for_mode (PhotosItemManager *self, PhotosWindowMode
 {
   PhotosBaseItem *item = NULL;
   PhotosBaseManager *item_mngr_chld;
+  gboolean is_collection;
   const gchar *id;
 
+  g_return_if_fail (PHOTOS_IS_ITEM_MANAGER (self));
+  g_return_if_fail (TRACKER_SPARQL_IS_CURSOR (cursor));
   g_return_if_fail (mode != PHOTOS_WINDOW_MODE_NONE);
   g_return_if_fail (mode != PHOTOS_WINDOW_MODE_EDIT);
   g_return_if_fail (mode != PHOTOS_WINDOW_MODE_PREVIEW);
 
+  is_collection = photos_item_manager_cursor_is_collection (cursor);
+  g_return_if_fail ((is_collection && mode == PHOTOS_WINDOW_MODE_COLLECTIONS)
+                    || (!is_collection && mode != PHOTOS_WINDOW_MODE_COLLECTIONS));
+
   item_mngr_chld = self->item_mngr_chldrn[mode];
   id = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_URN, NULL);
 


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