`self.update()` in method `start` of a `FilterWithDialog` throws error for selections

When a layer contains both paths and components, a Python FilterWithDialog plugin will fail to work if any of the elements are selected. This problem can always be reproduced, so long as the filter is written in Python. This appears to be a bug in GlyphsSDK.

Glyphs version: 3.1.1 (3148)
Python version: 3.9.1

Traceback (most recent call last):
  File "GlyphsApp/GlyphsApp/plugins.py", line 604, in process_
  File "GlyphsApp/GlyphsApp/__init__.py", line 522, in GSProxyShapes__getitem__
IndexError: list index out of range

Reproducing the problem with BroadNibber.

I found the issue and fixed it.

1 Like

Does the SDK release with the app, or could we update it by ourselves somehow?

can’t wait for it.

The SDK is in the app.
But you could copy a fixed version of the process_() method from the glyphsSDK version of the filter plugin.

1 Like

The problem still exists in v3.1.2, with a new error:

Traceback (most recent call last):
  File "GlyphsApp/GlyphsApp/plugins.py", line 613, in process_
AttributeError: 'GSComponent' object has no attribute 'nodes'

hmm @CelPhineas I have the same problem as yours.

Can you narrow it down to what plugin is causing this?

It appears to happen to all python FilterWithDialog plugins. I tried a plugin of mine under development, and BroadNibber, both of them encounters the identical problem.

Can you try Glyphs 3.2?

Thank you Georg. I can verify that the bug has been fixed in v3.2.

But one more problem, layer.components seem to be unselected when the function filter is called. This behavior is very different to layer.paths, from which I can still read the selection state of the paths.

A minimal example:

def filter(self, layer, inEditView, customParameters):
  print([ path.selected for path in layer.paths ])      # 1
  print([ comp.selected for comp in layer.components ]) # 2

When all the paths and components are selected, the first line will print all True s, while the second line will print all False s.

That is probably the least performant way to do this.

  1. In almost all cases, use layer.shapes and not layer.paths/components.
  2. to get to the selection, iterate over layer.selection instead of using shape.selected

Can you run the two lines in the macro panel to see if it works there?

1 Like