Skip to content

Commit b1f9ca3

Browse files
author
Fayvel Victor
committed
Fix recent_files config option automatically
The recent_files list has to be an python object serialization. This object must be an array of strings. Python will save unicode strings and Python3 strings. Not following this rule make m64py crash either while loading the recent_files information or when adding a new entry when a file is opened.
1 parent 4e1bc6b commit b1f9ca3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/m64py/frontend/recentfiles.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,18 @@ def create(self):
4949
self.action_clear_history.triggered.connect(self.clear)
5050
self.parent.menuRecent.addAction(self.action_clear_history)
5151

52+
def is_string(self, obj):
53+
try:
54+
return isinstance(obj, basestring)
55+
except NameError:
56+
return isinstance(obj, str)
57+
5258
def update(self):
5359
"""Updates list of recent files."""
5460
self.recent_files = self.parent.settings.qset.value("recent_files", [])
61+
if not type(self.recent_files) == list:
62+
self.recent_files = []
63+
self.recent_files = list(filter(lambda x: self.is_string(x), self.recent_files))
5564
num_files = min(len(self.recent_files), self.max_recent)
5665
for i in range(num_files):
5766
text = QFileInfo(self.recent_files[i]).fileName()

0 commit comments

Comments
 (0)