11-11-2025, 03:02 PM
That makes sense - I asked how we might gracefully determine if an image handle is associated with an image before doing _FreeImage and @SMcNeill had an answer that works for me...
Good to know about that maptriangle for filled triangles!
(11-11-2025, 12:53 AM)SMcNeill Wrote:and @RhoSigma had some good suggestions too:Code: (Select All)Just write your own freeimage routine and have it *always* set to handle back to 0 when it's freed the handle.
SUB FreeImage (handle AS LONG)
IF handle < -1 THEN
_FREEIMAGE handle
handle = 0
END IF
END SUB
If a handle isn't loaded at all, then it's going to be 0.
If a handle is > 0 then it's going to be a screen handle and not needing to be freed.
Only LOAD when handles are 0 or -1, and only FREE when the handle is < -1 and then set the handle back to 0.
It's about the easiest way to deal with the issue that I know of.
(11-11-2025, 10:33 AM)RhoSigma Wrote: IMO it should be handle = -1 instead of 0, as -1 is the official invalid image handle value, while 0 could be a screen page in legacy screens and get missinterpreted as the current destination page.One should be able to safely call that custom FreeImage routine at the end of a program or routine without having to worry about an error if the image has already been freed.
Best is probably to use the provided compiler constants, hence handle = _INVALID_IMAGE.
Good to know about that maptriangle for filled triangles!

