Hi Eros,
What is the interpreter doing after CloseWindow?
Do not performing this code!
#INCLUDE "A.inc"
Declare Function SetPixel Lib "gdi32.dll" Alias "SetPixelV" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
'test api pixel
Screen 320,240,1,"Let's begin" 'window 320x240 1 = windowed
Long x,hdc 'some variables
hdc=GetHandleDC() 'doublebuffer address
SetDirectory("RedBanana") 'Create Directory
While Key(27)=0 'wait for escape key
ClsColor Rgb 255,255,255 'clear screen with color white
SetText 120,120,"HELLO",0 'draw hello with color black
SetText 0,0,GetHandleDC(),0 'show DC address with color black
For x=0 To 319 'test loop
SetPixel hdc,x,100,255 'test line with color red
Next
FlipScreen 'doublebuffer to screen
Sleep 10 'reduce cpu power
Wend
CloseWindow 'quit
'< what is the interpreter doing here?
ErosOlmi
07-11-2012, 19:45
During stat and ending of thinBasic Core engine, a lot of things happen.
To list some of the one perfomed during script ending:
de-allocation of hash table used for external libraries used by the script
de-allocation of hash table used for language keywords (loaded dynamically by each module loaded by the script)
de-allocation of hash table used for global variables
de-allocation of hash table used for equates (constants) loaded by all module used in the script (only thinCore module loads more than 2000 constants)
de-allocation of hash table used for user functions and for all function parameters
I'm already debugging this area but is quite complex and full of complex structures.
Thanks Eros.
CloseWindow frees all loaded bitmaps and icons when neccessary.
After this, it destroys its window and lets do your interpreter his work.
Is something wrong in this cycle ?
I notice sometimes that the task manager needs some seconds to close a task.
And sometimes is still running a task in the background.
But I get never a crash.
This A.dll is a bridge to OxygenBasic. Both of them can perform the same source code.
Only OxygenBasic does his job correctly. No trouble hier!
Okay, try this
ErosOlmi
08-11-2012, 23:29
Sorry for the delay but I was busy at work.
CloseWindow frees all loaded bitmaps and icons when neccessary.
After this, it destroys its window and lets do your interpreter his work.
Is something wrong in this cycle ?
Absolutely not
I notice sometimes that the task manager needs some seconds to close a task.
And sometimes is still running a task in the background.
But I get never a crash.
This happens when you close windows created by external DLL and thinBasic does not know nothing about that.
If the window is created by an external DLL, thinBasic interpreter is still running the main loop because (I guess) there is nothing in the loop that stops it if the window is not on screen anymore.
If you are exiting from the main loop only when pressing a key (for example ESC) and not also when the window is not there, thinBasic is still executing the loop and that's why you will see the process still running.
So in your loop you should do something like
While [ESC has not been presses] AND [My Main Window is still there]
...
Wend
This A.dll is a bridge to OxygenBasic. Both of them can perform the same source code.
Only OxygenBasic does his job correctly. No trouble hier!
Charles is a great programmer.
Anyway, here I'm still getting GPF in both ghost examples but, as I said before, I'm still investigating if the problem is on my side.
What I can just see is that all seems happening during or just after the closing of the window.
Ciao
Eros