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.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user