Skip to content

Selected shape object disappears (undesired garbage collection?) #278

@olcc

Description

@olcc

Hello,

In the following script, shape s disappears even though it is still bound to an identifier. Is it normal? Can it be improved?

import pya
import time

layout_view = pya.LayoutView.current() 
     
def get_selection():
  return layout_view.object_selection
  
# We suppose that the selection contains shapes
shapes = [opath.shape for opath in get_selection()]

s = shapes[0]
print("Shape: {}".format(s))  # Shape: box (x;y)
time.sleep(1)
print("Shape: {}".format(s))  # Shape: null

Note: A workaround is to keep a reference to layout_view.object_selection. But, as said, it is a workaround. The shape object should normally survive without this workaround, no?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions