[gnome-photos] application: Avoid CRITICALs when going to EDIT and PREVIEW



commit e79a2c37f7d3a15514374795633762666b2acc5b
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Jan 18 18:07:15 2018 +0100

    application: Avoid CRITICALs when going to EDIT and PREVIEW
    
    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
    
    Fallout from d5d28be0e85adaa521c11a0c05ee317c8a3a2a54

 src/photos-application.c | 45 +++++++++++++++++++++++++++++++++++++++------
 1 file changed, 39 insertions(+), 6 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 4f8de9f4..4b9e7351 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -1629,19 +1629,52 @@ photos_application_window_mode_changed (PhotosApplication *self, PhotosWindowMod
 
   g_return_if_fail (mode != PHOTOS_WINDOW_MODE_NONE);
 
-  if (old_mode != PHOTOS_WINDOW_MODE_NONE)
+  switch (old_mode)
     {
+    case PHOTOS_WINDOW_MODE_NONE:
+    case PHOTOS_WINDOW_MODE_EDIT:
+    case PHOTOS_WINDOW_MODE_PREVIEW:
+      break;
+
+    case PHOTOS_WINDOW_MODE_COLLECTION_VIEW:
+    case PHOTOS_WINDOW_MODE_COLLECTIONS:
+    case PHOTOS_WINDOW_MODE_FAVORITES:
+    case PHOTOS_WINDOW_MODE_OVERVIEW:
+    case PHOTOS_WINDOW_MODE_SEARCH:
       item_mngr_chld = photos_item_manager_get_for_mode (PHOTOS_ITEM_MANAGER (self->state->item_mngr), 
old_mode);
       g_signal_handlers_disconnect_by_func (item_mngr_chld, photos_application_items_changed, self);
+      break;
+
+    default:
+      g_assert_not_reached ();
+      break;
     }
 
   photos_application_actions_update (self);
 
-  item_mngr_chld = photos_item_manager_get_for_mode (PHOTOS_ITEM_MANAGER (self->state->item_mngr), mode);
-  g_signal_connect_swapped (item_mngr_chld,
-                            "items-changed",
-                            G_CALLBACK (photos_application_items_changed),
-                            self);
+  switch (mode)
+    {
+    case PHOTOS_WINDOW_MODE_COLLECTION_VIEW:
+    case PHOTOS_WINDOW_MODE_COLLECTIONS:
+    case PHOTOS_WINDOW_MODE_FAVORITES:
+    case PHOTOS_WINDOW_MODE_OVERVIEW:
+    case PHOTOS_WINDOW_MODE_SEARCH:
+      item_mngr_chld = photos_item_manager_get_for_mode (PHOTOS_ITEM_MANAGER (self->state->item_mngr), mode);
+      g_signal_connect_swapped (item_mngr_chld,
+                                "items-changed",
+                                G_CALLBACK (photos_application_items_changed),
+                                self);
+      break;
+
+    case PHOTOS_WINDOW_MODE_EDIT:
+    case PHOTOS_WINDOW_MODE_PREVIEW:
+      break;
+
+    case PHOTOS_WINDOW_MODE_NONE:
+    default:
+      g_assert_not_reached ();
+      break;
+    }
 }
 
 


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