From b4017cfec2ee67857ff8ddbe7c7d930cea57ec04 Mon Sep 17 00:00:00 2001 From: Juan Pablo Caram Date: Sat, 2 Jul 2016 17:36:19 -0400 Subject: [PATCH] Update instead of setting options when reading project. Fixes #204. --- FlatCAMObj.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/FlatCAMObj.py b/FlatCAMObj.py index a3d7610f..8860bcb9 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -49,6 +49,23 @@ class FlatCAMObj(QtCore.QObject): # self.ui.offset_button.clicked.connect(self.on_offset_button_click) # self.ui.scale_button.clicked.connect(self.on_scale_button_click) + def from_dict(self, d): + """ + This supersedes ``from_dict`` in derived classes. Derived classes + must inherit from FlatCAMObj first, then from derivatives of Geometry. + + ``self.options`` is only updated, not overwritten. This ensures that + options set by the app do not vanish when reading the objects + from a project file. + """ + + for attr in self.ser_attrs: + + if attr == 'options': + self.options.update(d[attr]) + else: + setattr(self, attr, d[attr]) + def on_options_change(self, key): self.emit(QtCore.SIGNAL("optionChanged"), key)