navigation-view: Fix segfault when removing all pages
Looks like commit d4ff98ff exposed an edge case that's triggered in Builder when closing the tweaks window. Specifically in src/libide/tweaks/ide-tweaks-window.c#L145
when it calls adw_navigation_view_replace (self->sidebar_nav_view, NULL, 0)
.
This can be pretty easily reproduced on the Builder nightly flatpak by:
- opening Builder
- opening the Preferences window
- clicking the
Appearance
tab - clicking a few different color schemes (might not be necessary)
- closing the tweaks window
Calling g_list_store_remove_all() on L2882 causes a subsequent call to ADW_IS_NAVIGATION_PAGE (old_visible_page) in adw_navigation_page_get_tag() to segfault when removing all pages. Guard against this when removing all pages from the view.
Also fix indentation.
Edit: didn't check the tests, but I should have. It's failing one of them. I'll try to fix it before I mark the MR as ready again.
Edited by Caleb Gartner