Skip to content

Commit

Permalink
Merge pull request #333 from robotools/restore_identifiers
Browse files Browse the repository at this point in the history
restore identifiers after setDataFromSerialization
  • Loading branch information
benkiel committed Jan 26, 2021
2 parents 4022a95 + 039fbb8 commit 65c3bf4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Lib/defcon/objects/glyph.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,13 @@ def _fullyLoadShallowLoadedContours(self):
self.dirty = dirty
self.enableNotifications()

def instantiateContour(self):
def instantiateContour(self, contourDict=None):
contour = self._contourClass(
glyph=self,
pointClass=self.pointClass
)
if contourDict is not None:
contour.setDataFromSerialization(contourDict)
return contour

def beginSelfContourNotificationObservation(self, contour):
Expand Down Expand Up @@ -684,10 +686,12 @@ def _get_components(self):

components = property(_get_components, doc="An ordered list of :class:`Component` objects stored in the glyph.")

def instantiateComponent(self):
def instantiateComponent(self, componentDict=None):
component = self._componentClass(
glyph=self
)
if componentDict is not None:
component.setDataFromSerialization(componentDict)
return component

def beginSelfComponentNotificationObservation(self, component):
Expand Down Expand Up @@ -1100,9 +1104,10 @@ def _get_imageClass(self):

imageClass = property(_get_imageClass, doc="The class used for the image.")

def instantiateImage(self):
def instantiateImage(self, imageDict=None):
image = self._imageClass(
glyph=self
glyph=self,
imageDict=imageDict
)
return image

Expand Down Expand Up @@ -1371,8 +1376,7 @@ def wrapper(key, data):
return wrapper

def single_init(factory, data):
item = factory()
item.setDataFromSerialization(data)
item = factory(data)
return item

def list_init(factory, data):
Expand Down

0 comments on commit 65c3bf4

Please sign in to comment.