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



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

    item-manager: Be more strict about what is acceptable
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770342

 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..c6d7cd1 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 || mode == 
PHOTOS_WINDOW_MODE_SEARCH))
+                    || (!is_collection && (mode != PHOTOS_WINDOW_MODE_COLLECTIONS || self->active_collection 
!= NULL)));
+
   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]