orx icon indicating copy to clipboard operation
orx copied to clipboard

[orx-gui] Make `gui.shutdown()` clean up after itself

Open hamoid opened this issue 2 years ago • 3 comments

Motivation

I would like to be able to extend(gui), later do gui.shutdown() and once again extend(gui).

Currently gui adds listeners for key presses and maintains mutable lists which are not cleared on shutdown. It seems to assume that a program has one gui which exists for the duration of the program.

More generally, there's gui.add() but no gui.remove(), there's program.extend() but no program.drop().

Help make it happen!

I am willing to submit a PR to implement this change, but would need some guidance.

hamoid avatar Aug 10 '22 15:08 hamoid

On that note, I see a similar problem with [orx-compositor]. There are funtions provided ike deepDestroy that would allow cleanup, but the important vars themselfs are kept private.

This follows the same logic of providing creation, but no kind of destruction.

In general, I would welcome opening up resources to follow the acquire-release pattern. This allows for dynamic usage of resources, acquiring and releasing them as needed.

Note: My personal motivation is using orx-compisitor for scenes (like theaters scenes) were I have to cleanup resources after a scene completes. (I define many scenes in advance, but only one is in active use at any point.) I hope it's understandable how this benefit similar dynamic projects.

Treide1 avatar Jun 04 '23 19:06 Treide1

I am also willing to write a PR for orx-compositor specifically. I would like a second opionion before authoring it though.

Treide1 avatar Jun 04 '23 19:06 Treide1

Admittedly orx-compositor is written entirely without thinking of releasing resources.

OPENRNDR has a hidden resource manager provided by Session, it is primarily used to release resources in the live coding mode provided by orx-olive. It may be worthwhile to formalize/untangle what Session does and document the API. It may be possible to create a scene inside a Session scope and have all the resources cleaned up automatically by closing the session.

edwinRNDR avatar Jun 05 '23 08:06 edwinRNDR