Move all preference panel init to 'populate' methods that are called on selecting them; this leaves the rest of the preferences dialog usable even if one panel crashes when initialized this way.

Should help with #5526
This commit is contained in:
Daniel Johnson 2024-06-30 15:49:06 -04:00
parent 696219fef1
commit 8d6b1a0576
3 changed files with 8 additions and 6 deletions

View file

@ -65,13 +65,17 @@ class PreferencesDialog(GameDialogCommon):
self.page_generators["accounts-stack"] = accounts_box.populate_steam_accounts
self.stack.add_named(self.build_scrolled_window(accounts_box), "accounts-stack")
self.stack.add_named(self.build_scrolled_window(UpdatesBox()), "updates-stack")
updates_box = UpdatesBox()
self.page_generators["updates-stack"] = updates_box.populate
self.stack.add_named(self.build_scrolled_window(updates_box), "updates-stack")
sysinfo_box = SystemBox()
self.page_generators["sysinfo-stack"] = sysinfo_box.populate
self.stack.add_named(self.build_scrolled_window(sysinfo_box), "sysinfo-stack")
self.stack.add_named(self.build_scrolled_window(StorageBox()), "storage-stack")
storage_box = StorageBox()
self.page_generators["storage-stack"] = storage_box.populate
self.stack.add_named(self.build_scrolled_window(storage_box), "storage-stack")
self.system_box = SystemConfigBox(self.config_level, self.lutris_config)
self.page_generators["system-stack"] = self.system_box.generate_widgets

View file

@ -11,8 +11,7 @@ from lutris.runners.runner import Runner
class StorageBox(BaseConfigBox):
def __init__(self):
super().__init__()
def populate(self):
self.add(self.get_section_label(_("Paths")))
path_widgets = self.get_path_widgets()
self.pack_start(self._get_framed_options_list_box(path_widgets), False, False, 0)

View file

@ -25,8 +25,7 @@ LUTRIS_EXPERIMENTAL_FEATURES_ENABLED = os.environ.get("LUTRIS_EXPERIMENTAL_FEATU
class UpdatesBox(BaseConfigBox):
def __init__(self):
super().__init__()
def populate(self):
self.add(self.get_section_label(_("Wine update channel")))
update_channel_radio_buttons = self.get_update_channel_radio_buttons()