Gregory,
>
> Good luck. I know it may take some time. Oh and do share
> the results, maybe there's point 4)
>
Arrrghh!!
OK, here it is: In order to be able to run isolated forms and processes during development (and for safety-reasons during runtime), most of my classes and forms check if everything is as they need it. There is an Application-Object, a global Eventhandler, one or the other procedure that needs to be set in order to run everything smooth.
so there is a call like
do CheckEnvironment in PROC_SCHEDCUST.FXP
and this
of course does something like
if type("goApp") # "O" or isNull(goApp)
public goAPP
goApp = NewObject(ccApplicationClassName, ccApplicationClassLib, "", gc_ThisINI)
endif
!BINGO!
In "real life" in the EXE this actually never happens as this stuff is checked and created from the main prog and therefore in DataSession 1.
Interestingly enough, although the App-Object for instance is NOT a session it still runs in the session it's been created in, even if the form that caused the "trouble" is gone for ages - just as You already mentioned it with the SCATTER MEMVAR NAME.
Not really surprising if You think of it, but!, You need to think of it to avoid it ;-)
I added a small method to the application-Class, that shows the effect.
PROCEDURE MySession
acti screen
? "Hi, My name is "+ this.Name +" and I am currently working in Datasession "+ trans(set("Datasession"))
ENDPROC
BTW, in contrast to Dangling References, releasing the affected Objects will properly close the "Dangling Datasession".
For all the others, that possibly but hopefully never trap into this, here the solution:
Put your global stuff into a Method that checks the current DataSession and if necessary changes it to 1. At the end reSet it to the correct DS.
Something like this
LOCAL lnWasSession
lnWasSession = set("DATASESSION")
if lnWasSession # 1
set Datasession to 1
endif
if type("goApp") # "O" or isNull(goApp)
public goAPP
goApp = NewObject(ccApplicationClassName, ccApplicationClassLib, "", gc_ThisINI)
endif
....
set Datasession to lnWasSession
return .T.
Thanks for giving me a hand on this.