diff options
author | António Fernandes <antoniof@gnome.org> | 2022-12-20 00:03:29 +0000 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2022-12-23 18:33:13 +0000 |
commit | fdbbb72be3bd720f4172738a4e0a3f1abd4501bd (patch) | |
tree | db6aa294cc16315190089f5339578f2bd3bf2010 | |
parent | b8dd87ec10c9843071a0d6ac9dcfcc80c7a185d1 (diff) | |
download | nautilus-fdbbb72be3bd720f4172738a4e0a3f1abd4501bd.tar.gz |
window-slot: Handle broken default-folder-viewer
0 became the invalid id in 7c30c311e619a4d1c1d6b96f2095e5d63cfe2478
GSettings may give us an the invalid view id (e.g. if the stored value
doesn't match any string defined in the schemas). This may happen if
the backend is corrupted or the installed schemas are outdated, and it
leaves the application in a broken state.
So, handle this case, warning the user about the issue but falling
back to a valid view id.
Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2576
-rw-r--r-- | src/nautilus-window-slot.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index 557b98411..49fa95faa 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -307,6 +307,13 @@ nautilus_window_slot_get_view_for_location (NautilusWindowSlot *self, { view_id = g_settings_get_enum (nautilus_preferences, NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER); } + if (view_id == NAUTILUS_VIEW_INVALID_ID) + { + g_warning ("Invalid value stored for 'default-folder-viewer' key for " + "the 'org.gnome.nautilus.preferences' schemas. Installed " + "schemas may be outdated. Falling back to 'list-view'."); + view_id = NAUTILUS_VIEW_LIST_ID; + } /* Try to reuse the current view */ if (nautilus_window_slot_content_view_matches (self, view_id)) |