Fix IndexError that sometimes occurs when changing view

This occurs when restarting Gramps.

Fixes #12636, #12304, #12429, #12623, #12695.
This commit is contained in:
SNoiraud 2022-09-27 11:52:04 +02:00 committed by Nick Hall
parent 4ebba02b6b
commit d5d86e9139

View File

@ -786,7 +786,12 @@ class ViewManager(CLIManager):
self.__create_page(page_def[0], page_def[1])
self.notebook.set_current_page(page_num)
try:
return self.pages[page_num]
except IndexError:
# The following is to avoid 'IndexError: list index out of range'
# Should solve bug 12636
return self.pages[0]
def get_category(self, cat_name):
"""
@ -880,7 +885,12 @@ class ViewManager(CLIManager):
"""
self.__disconnect_previous_page()
# The following is to avoid 'IndexError: list index out of range'
# Bugs: 12304, 12429, 12623, 12695
try:
self.active_page = self.pages[page_num]
except IndexError:
self.active_page = self.pages[0]
self.__connect_active_page(page_num)
self.active_page.set_active()
while Gtk.events_pending():