What happens with an orphaned scenenode?

If a plugin holds on to a scenenode reference, and that node is deleted by the user via the UI (or some other plugin deletes it), I assume the reference is still valid (until it’s no longer in use, of course, and garbage collected), but the .isInArtworkTree property just goes false?

(This is not a theoretical question.)

If the node is deleted by the user, your plugin won’t be able to do anything to the node that does not exist any more. What would be the use case?

If a panel plugin kept a reference to a node across update calls for any number of reasons, it could detect that the .isInArtworkTree and drop the reference.

Got it. if the node is removed, isInArtworkTree will be false

I guess what I’m trying to confirm is that the node won’t be garbage-collected as long as a plugin has a handle on it, right?

(This may be a deep question, I realize.)

I’m not 100% sure here; the object that the plugin has hold of is actually a wrapper, not the real thing. @peterflynn / @schenglooi, do either of you have any thoughts here?

A SceneNode is a Proxy? That’s pretty slick. Is that common practice for preventing strong references (that prevent garbage collection)?

It’s gotta be a wrapper, since the JS object and the C++ internal object can’t really be the same.

I’m asking if the wrapper is effectively a strong reference or not. I’m sure hoping it is…

Right it’s a wrapper class. Not a Proxy pattern, but a proxy in definition.

I think it is strong reference because it still exists if you delete from the stage. For example, cut an element and then do some other changes and then paste the element. It still exists it’s just not on the artboard.

Yes, I realized it was a silly question in the end.

E.g., when you first create a node, it’s not in the artwork tree. When you remove it from its parent, it’s no longer in the tree. But it’s got to function normally otherwise, q.e.d., it’s a strong reference.