From f58c20afecc8488ccd968708b38eec8955faa45c Mon Sep 17 00:00:00 2001 From: furti Date: Tue, 18 Jun 2019 19:46:21 +0200 Subject: [PATCH] Fix some problems with ArchFence The commit that introduces the colorization option added some problems. First the "sectionFaceNumbers" property is only set when an execute is performed. When this does not happen, an exception is thrown when the document is saved that contains a fence created with an older version of FreeCAD. Also the new Props on the ViewProvider where not set because the "onDocumentRestored" is not reckognized for ViewProviders. --- src/Mod/Arch/ArchFence.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Mod/Arch/ArchFence.py b/src/Mod/Arch/ArchFence.py index edc59fd797..be27634656 100644 --- a/src/Mod/Arch/ArchFence.py +++ b/src/Mod/Arch/ArchFence.py @@ -59,7 +59,10 @@ class _Fence(ArchComponent.Component): self.Type = "Fence" def __getstate__(self): - return (self.sectionFaceNumbers) + if hasattr(self, 'sectionFaceNumbers'): + return (self.sectionFaceNumbers) + + return None def __setstate__(self, state): if state is not None and isinstance(state, tuple): @@ -237,9 +240,11 @@ class _ViewProviderFence(ArchComponent.ViewProviderComponent): vobj.addProperty("App::PropertyBool", "UseOriginalColors", "Fence", QT_TRANSLATE_NOOP( "App::Property", "When true, the fence will be colored like the original post and section.")) - def onDocumentRestored(self, vobj): + def attach(self, vobj): self.setProperties(vobj) + return super().attach(vobj) + def getIcon(self): import Arch_rc