From 1f36ed9369c39981056c15c538610b63fe173921 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Thu, 23 Apr 2020 02:43:26 +0300 Subject: [PATCH] - added an extra check if old preferences files are detected, a check if the type of the values is the same with the type in the current preferences file. If the type is not the same then the current type is preferred. --- CHANGELOG.md | 1 + FlatCAMApp.py | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 617a38d1..4bfb98c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ CHANGELOG for FlatCAM beta - added a 'Close' menu entry in the Tcl Shell context menu that will close (hide) the Tcl Shell Dock widget - on launching the Tcl Shell the Edit line will take focus immediately - in App.on_mouse_move_over_plot() method no longer will be done a setFocus() on every move, only when it is needed +- added an extra check if old preferences files are detected, a check if the type of the values is the same with the type in the current preferences file. If the type is not the same then the current type is preferred. 22.04.2020 diff --git a/FlatCAMApp.py b/FlatCAMApp.py index d366afa8..fab021b4 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -3829,7 +3829,23 @@ class App(QtCore.QObject): if 'version' not in defaults or defaults['version'] != self.defaults['version']: for k, v in defaults.items(): if k in self.defaults and k != 'version': - self.defaults[k] = v + + # check if the types are the same. Because some types (tuple, float, int etc) + # may be stored as strings we check their types. + try: + target = eval(self.defaults[k]) + except NameError: + # it's an unknown string leave it as it is + target = deepcopy(self.defaults[k]) + + try: + source = eval(v) + except NameError: + # it's an unknown string leave it as it is + source = deepcopy(v) + + if type(target) == type(source): + self.defaults[k] = v # delete old factory defaults try: