gal-view-instance: Do not crash on broken setup

When there's saved an unknown view, which cannot be loaded, the code
could crash. This change makes sure the first view in the collection
will be loaded, instead of crashing the application.
This commit is contained in:
Milan Crha
2022-03-25 07:49:58 +01:00
parent f9321d99f0
commit d3a28f64c2

View File

@ -315,6 +315,12 @@ load_current_view (GalViewInstance *instance)
g_free (type);
}
if (view == NULL) {
/* If everything fails, maybe due to broken setup, default to the first view in the collection. */
view = gal_view_collection_get_view (instance->collection, 0);
view = gal_view_clone (view);
}
connect_view (instance, view);
xmlFreeDoc (doc);