jgraphics_destroy

Roby Steinmetzer's icon

In the provided UI examples of the SDK 5 jgraphics_destroy() to free
an existing graphic context is only used in uitester.
Does this mean it is not mandatory?

Thanks

Rob Sussman's icon

You should only destroy graphics contexts that you create. Thus, if you call jgraphics_create() then you must call jgraphics_destroy() when you are done with it or else you will have a memory leak.

A graphics context that you get from the patcherview during a paint method (i.e. via patcherview_get_jgraphics()) is not owned by you thus you better not free it (or else it will crash).

Looking at the usage of jgraphics_create() in uitester.c it seems that both the uitester_scroll() and snippet_offscreen() functions are missing jgraphics_destroy() calls.

Rob