Python copyDecomposedLayer() bug

In the current beta (1086), I am getting the following Python error:

   print layer.copyDecomposedLayer().background
  File "GlyphsApp/__init__.py", line 4865, in Layer__repr__
    
  File "GlyphsApp/__init__.py", line 4865, in Layer__repr__

[lots more of these]
        
  File "GlyphsApp/__init__.py", line 4865, in Layer__repr__
    
RuntimeError: maximum recursion depth exceeded

It even breaks the undo so I am losing part of my work.

It has nothing with layer.copyDecomposedLayer() but just printing the background. I fixed it.

1 Like

Thanks, it does not crash any more.

However, layer.copyDecomposedLayer().background does not contain any paths (but the background does, and layer.background.paths does as well).

Why do you need to have a decomposedCopy?

Why do you need to have a decomposedCopy?

As far as I remember, I used the method to get a deep copy of the layer because otherwise, if I delete the background path, the foreground will be deleted, too. Similarly, using layer.paths.append( GSPath( path ) ) further below does not wirk. Seems like all the copy constructiors are somewhat broken?

It is part of my Mask to Master macro:

Using the copy constructor, i.e. iterating over GSLayer( layer ).background.paths should be the official solution but it does not work. Similarly, using layer.paths.append( GSPath( path ) ) further below does not work. Seems like all the copy constructors are somewhat broken?

Any suggestions how to get it to work in the latest Glyphs version?

this works for me:

	for path in layer.background.paths:
		# copy across path
		layer.paths.append( path.copy() )

Thanks, this works. Just wondering why the copy constructor does not return the same as .copy(), and why we need the latter at all.

The GS-classes are cocoa classes and thous work a bit differently then pure python classes.

1 Like