[gnome-photos] embed: Don't restore an invalid search state
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] embed: Don't restore an invalid search state
- Date: Fri, 2 Feb 2018 22:04:44 +0000 (UTC)
commit 934297ccf0c137fa698685707994e6780d3b8bb8
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Feb 2 21:35:57 2018 +0100
embed: Don't restore an invalid search state
It's possible that the Source that's part of the saved SearchState is
no longer available when restoring. eg., if the Source was removed
while viewing a search result. Restoring the search state to that
Source would lead to:
CRITICAL **: photos_base_manager_set_active_object: assertion
'PHOTOS_IS_FILTERABLE (object)' failed
Care should be taken to set the source to "all". If the Source was the
only search constraint, then it will no longer meet the requirements
for SEARCH and should go back to the previous mode.
src/photos-embed.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/src/photos-embed.c b/src/photos-embed.c
index 03c9ed5d..09f5bf50 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -214,15 +214,25 @@ static void
photos_embed_restore_search (PhotosEmbed *self)
{
GVariant *state;
+ PhotosSource *source;
+ const gchar *id;
if (!self->search_state.saved)
return;
photos_embed_block_search_changed (self);
- photos_base_manager_set_active_object (self->src_mngr, self->search_state.source);
+
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (self->search_state.source));
+ source = PHOTOS_SOURCE (photos_base_manager_get_object_by_id (self->src_mngr, id));
+ if (source == NULL)
+ id = PHOTOS_SOURCE_STOCK_ALL;
+
+ photos_base_manager_set_active_object_by_id (self->src_mngr, id);
+
photos_base_manager_set_active_object (self->srch_mtch_mngr, self->search_state.search_match);
photos_base_manager_set_active_object (self->srch_typ_mngr, self->search_state.search_type);
photos_search_controller_set_string (self->srch_cntrlr, self->search_state.str);
+
photos_embed_unblock_search_changed (self);
self->search_state.saved = FALSE;
@@ -484,8 +494,15 @@ photos_embed_prepare_for_search (PhotosEmbed *self, PhotosWindowMode old_mode)
if (old_mode == PHOTOS_WINDOW_MODE_PREVIEW)
photos_embed_tracker_controllers_set_frozen (self, FALSE);
- photos_spinner_box_stop (PHOTOS_SPINNER_BOX (self->spinner_box));
- gtk_stack_set_visible_child_name (GTK_STACK (self->stack), "search");
+ if (photos_embed_is_search_constraint_present (self))
+ {
+ photos_spinner_box_stop (PHOTOS_SPINNER_BOX (self->spinner_box));
+ gtk_stack_set_visible_child_name (GTK_STACK (self->stack), "search");
+ }
+ else
+ {
+ photos_mode_controller_go_back (self->mode_cntrlr);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]