Really closing a stack
Graham Samuel
livfoss at mac.com
Mon Mar 4 08:02:27 EST 2013
This is driving me nuts. My ambition is to remove a stack from memory and therefore from the message path, prior to reloading a fresh (template) version of the same stack. I don't want two versions of the same stack in the machine at one time - and in fact LC makes this illegal. This seems a very simple idea but somehow I have messed it up. I need help.
After lots of experiments, I have made a very simple pair of stacks, as follows.
The first stack, 'Killer', is just a mainstack with one card and two buttons, one which loads the second stack ('DataStack') and one which destroys the data stack. The loading (opening) button works, and I can see the loaded stack in the IDE's Application Browser.
The script of the second button consists of just this:
on mouseUp
if exists(stack "dataStack") then
answer "deleting" && (the short name of stack "dataStack") & "; destroyStack is" && (the destroyStack of stack "dataStack") & "; cantDelete is" && (the cantDelete of stack "dataStack")
delete stack "dataStack" -- this is supposed to guarantee the removal from RAM
answer "the existence of the stack is now" && (exists(stack "dataStack"))
else
answer "can't find the data stack"
end if
end mouseUp
when I execute this, the first 'answer' reveals that the destroyStack is true and the cantDelete is false, but after the delete, the second answer confirms that stack still exists! I can also continue to access it from the IDE's App Browser. If I use 'close' instead of 'delete', I get the same result.
I also notice that an attempt to invoke the IDE's 'Close and Remove from Memory' menu doesn't work either - I get the warning dialog but the stack doesn't go away. This menu item works for me in other apps, even with this version of LC (5.5.4 on a Mac). I have no idea what new factor I have introduced. I have often restarted LC as part of this experiment, so it's not some bit of ragged code in the IDE.
I tried making my KIller stack into a standalone, and although the window of the data stack closes, its existence is still reported as 'true'. I tried using 'close' instead of 'delete', but the behaviour seems the same.
Can anyone explain this? This is probably just a consequence of 'developer fatigue', but I can't see it.
TIA
Graham
More information about the use-livecode
mailing list