Code: (Select All)
SUB FreeImage (handle AS LONG)
IF handle < -1 THEN
_FREEIMAGE handle
handle = 0
END IF
END SUB
Just write your own freeimage routine and have it *always* set to handle back to 0 when it's freed the handle.
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.

