on shutdown

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

on shutdown

Post by adventuresofgreg » Wed Oct 24, 2012 12:35 am

Hi: I'm having some problem shutting all substacks down on shutdown. I'm not sure why this is happening, but when i shutdown my main stack, the sub stacks don't close. and if I manually shut them down as well, the app stays in memory as a process. This is what i have in the hander "on shutdown". Note - the line "if the name of this stack..." is there because I can shut down the sub stacks and I don't want to shut down the main stack. I only want to shut everything down, and clear memory out if I shut down the main stack called "G59"

on shutdown
if the name of this stack contains "G59" then
close stack "BackTestLookup"
close stack "control panel"
close stack "trading results"

set the destroystack of stack "BackTestLookup" to true
  set the destroywindow of stack "BackTestLookup" to true  

set the destroystack of stack "control panel" to true
  set the destroywindow of stack "control panel" to true  

set the destroystack of stack "trading Results" to true
  set the destroywindow of stack "trading Results" to true  

set the destroystack of this stack to true
  set the destroywindow of this stack to true  

  lock messages
  quit
end if
end shutdown

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10356
Joined: Wed May 06, 2009 2:28 pm

Re: on shutdown

Post by dunbarx » Wed Oct 24, 2012 2:04 am

Hi.

It matters when you set the destroystack property.

If you have a button somewhere that says:

close stack "yourStack"
set the destroyStack of stack "yourStack" to "true"

the first time you invoke the handler, the stack will close, and the destroyStack will be set, but the stack will remain in memory. You can open the stack again, and since it is in memory you can do that from a simple:

open stack "yourStack" (in a handler somewhere).

But then if you run the close handler again, since the property was in fact set, though after it was closed that first time, then the stack closes out completely, purged from memory. But that simple "open" handler will no longer work. You would have to reopen from the finder or from a handler that contains the stack pathname.

Is this clear? Bottom line, place the "destroyStack" stuff before the "close" stuff.

Craig Newman

Post Reply