Commit e6fc52ae authored by Guillaume Seguin's avatar Guillaume Seguin

Harden a tiny bit against recent_files list load failures

parent 749a8566
...@@ -836,6 +836,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>.""" ...@@ -836,6 +836,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
def update_recent_files(self, param, value): def update_recent_files(self, param, value):
if self.filehistory is None: if self.filehistory is None:
return return
recent_files = []
try: try:
recent_files = json.loads(value) recent_files = json.loads(value)
except: except:
...@@ -1641,7 +1642,12 @@ Printrun. If not, see <http://www.gnu.org/licenses/>.""" ...@@ -1641,7 +1642,12 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self.set("last_file_path", path) self.set("last_file_path", path)
try: try:
abspath = os.path.abspath(name) abspath = os.path.abspath(name)
recent_files = []
try:
recent_files = json.loads(self.settings.recentfiles) recent_files = json.loads(self.settings.recentfiles)
except:
self.logError(_("Failed to load recent files list:") +
"\n" + traceback.format_exc())
if abspath in recent_files: if abspath in recent_files:
recent_files.remove(abspath) recent_files.remove(abspath)
recent_files.insert(0, abspath) recent_files.insert(0, abspath)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment