Skip to content

Commit ba9894b

Browse files
authored
Fix recent files (#198)
Ensure that `petab_gui.controllers.utils.RecentFilesManager.load_recent_files` always returns a list of strings. It seems there is some serialization issue for `list[str]` of length 1 (sometimes?!). Fixes #122.
1 parent 3e76d02 commit ba9894b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/petab_gui/controllers/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,14 @@ def add_file(self, file_path):
289289
self.update_tool_bar_menu()
290290

291291
@staticmethod
292-
def load_recent_files():
292+
def load_recent_files() -> list[str]:
293293
"""Load recent files from settings."""
294-
return settings_manager.get_value("recent_files", [])
294+
recent_files = settings_manager.get_value("recent_files", [])
295+
# for reasons yet unknown, this can be a single string
296+
# instead of a list at times
297+
if isinstance(recent_files, list):
298+
return recent_files
299+
return [recent_files]
295300

296301
def save_recent_files(self):
297302
"""Save recent files to settings."""

0 commit comments

Comments
 (0)