Take this example code:
Code: Select all
#include "ogl.bi"
using OGL
dim as MSG msg
dim as GUIWIN win = GUIWIN(5, 5, 300, 200)
do
waitevent_all(msg)
loop until uponclose_any(msg)
'HERE you should take note
win.destructor
'you'll need -s console: in -s gui mode, this issue doesn't occur...
But then the program decides to try and destroy win AGAIN, upon the program terminating, causing ending crash.
This is especially weird because no destructor of win is called if win.destructor isn't there (I've tested using print statements of the different components of the destruction). EDIT: I lied, I've tested it again, and yes, the destructor is called when program ends. As I will say, I'd like the user to destroy a GUIWIN object, whenever they'd like. Is this possible to do safely without using pointers?
Ideally, I would like the user of my library to be able to destroy a GUIWIN object without crashes. They should be able to call the destructor in some way (with or without pointers: the user shouldn't have to care).
This problem is apparent ever since OGL version 2.0. However, this problem was also apparent in OGL 1.0 and 1.1, but I then programed the destructor in such a way as to worry if I destroy anything at all...
Is this my library, or this a behaviour with FB which I should be aware about? If it's my library, what can I do to stop the crashes? If it's FB, which process should I take to destroy GUIWIN objects without crashes i.e. safely?
If I can fix the problem, I'll release a 2.2 fixing this issue, because it's really buggy me.
Thanks again.