[gnome-photos/wip/rishi/manager-model: 1/8] main-toolbar: Avoid CRITICALs when activating an item



commit 49ee17a6f87a8a3315fe7735c8327d2bebea5302
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Dec 6 09:10:18 2016 +0100

    main-toolbar: Avoid CRITICALs when activating an item
    
    There are no child BaseManagers for the EDIT and PREVIEW modes. Hence
    it lead to:
      CRITICAL **: photos_item_manager_get_for_mode: assertion
        'mode != PHOTOS_WINDOW_MODE_PREVIEW' failed
    
    This is also a good time to use a switch statement instead of if,
    because -Wswitch-enum will warn us if there are any additions to
    PhotosWindowMode.
    
    Fallout from 9f749767ac233270ffc58e423e83f09511bc2434
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775562

 src/photos-main-toolbar.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-main-toolbar.c b/src/photos-main-toolbar.c
index 78c1208..1d31234 100644
--- a/src/photos-main-toolbar.c
+++ b/src/photos-main-toolbar.c
@@ -290,8 +290,21 @@ photos_main_toolbar_items_changed (PhotosMainToolbar *self)
   guint n_items;
 
   window_mode = photos_mode_controller_get_window_mode (self->mode_cntrlr);
-  if (window_mode == PHOTOS_WINDOW_MODE_NONE)
-    return;
+  switch (window_mode)
+    {
+    case PHOTOS_WINDOW_MODE_NONE:
+    case PHOTOS_WINDOW_MODE_EDIT:
+    case PHOTOS_WINDOW_MODE_PREVIEW:
+      return;
+      break;
+
+    case PHOTOS_WINDOW_MODE_COLLECTIONS:
+    case PHOTOS_WINDOW_MODE_FAVORITES:
+    case PHOTOS_WINDOW_MODE_OVERVIEW:
+    case PHOTOS_WINDOW_MODE_SEARCH:
+    default:
+      break;
+    }
 
   item_mngr_chld = photos_item_manager_get_for_mode (PHOTOS_ITEM_MANAGER (self->item_mngr), window_mode);
   n_items = g_list_model_get_n_items (G_LIST_MODEL (item_mngr_chld));


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