From c27a69d5c11f6fac445161474ba681d462b16af9 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Thu, 31 Dec 2020 19:29:56 +0200 Subject: [PATCH] - fixed issue with not being able to mill holes in a Excellon object part of a loaded project (JSON serialization makes all keys in dictionary strings so I had to make sure that the obj.tools dict keys are made integers on project reconstruction) --- CHANGELOG.md | 1 + app_Main.py | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5a69b98..3683b080 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ CHANGELOG for FlatCAM beta - fixed parseDXF() class imports to work with newer versions of ezdxf module (starting with 0.15) - contribution of Maurizio D'Addona and Hans Boot - fixed a string ("Penelization Reference") by Hans Boot contribution. - fixed a string ("Penelization Reference") translations by Hans Boot contribution. +- fixed issue with not being able to mill holes in a Excellon object part of a loaded project (JSON serialization makes all keys in dictionary strings so I had to make sure that the obj.tools dict keys are made integers on project reconstruction) 30.12.2020 diff --git a/app_Main.py b/app_Main.py index 0f38fb8a..f82a4df9 100644 --- a/app_Main.py +++ b/app_Main.py @@ -11024,16 +11024,31 @@ class MenuFileHandlers(QtCore.QObject): self.log.debug(" **************** Started PROEJCT loading... **************** ") for obj in d['objs']: - def obj_init(obj_inst, app_inst): - try: - obj_inst.from_dict(obj) - except Exception as erro: - app_inst.log.error('MenuFileHandlers.open_project() --> ' + str(erro)) - return 'fail' - self.log.debug( "Recreating from opened project an %s object: %s" % (obj['kind'].capitalize(), obj['options']['name'])) + def obj_init(new_obj, app_inst): + + def worker_task(): + with app_inst.proc_container.new('%s...' % _("Opening")): + try: + new_obj.from_dict(obj) + + # try to make the keys in the tools dictionary to be integers + # JSON serialization makes them strings + # not all FlatCAM objects have the 'tools' dictionary attribute + try: + new_obj.tools = { + int(tool): tool_dict for tool, tool_dict in list(new_obj.tools.items()) + } + except AttributeError: + pass + except Exception as erro: + app_inst.log.error('MenuFileHandlers.open_project() --> ' + str(erro)) + return 'fail' + + app_inst.worker_task.emit({'fcn': worker_task, 'params': []}) + # for some reason, setting ui_title does not work when this method is called from Tcl Shell # it's because the TclCommand is run in another thread (it inherit TclCommandSignaled) if cli is None: