Replacing a stack

Shari shari at gypsyware.com
Mon Oct 22 16:40:18 EDT 2007


>Execute the revert command after you download the preferences stack:
>
>   revert stack prefsLocation
>
>What the revert command does is reload the stack from the copy on 
>disk, replacing the copy in memory. Since the disk copy is the new 
>version, this will suck the new version into memory, replacing the 
>old one.


Is there any chance that a stack remains in memory and that Rev 
recreates it without my code telling it to?  In my uninstaller, after 
it deletes the preference stack, I discovered awhile back that my app 
must immediately quit.  Otherwise things would reappear.  Nowhere in 
my code does it say to create a stack, except in the startup routine. 
Once the app is fully launched, it does not ever create a stack.  I 
am wondering if this is what's happening now when trying to replace a 
stack.  Jeanne, I added revert as follows, and the app fails to 
launch at all.

Also, if I quit the app and open the pref stack manually and check 
the xVersion, it shows that it's the old version, not the new one. 
So it isn't just in memory, the actual stack is wrong.  So the new 
version never seems to get created.  The old one is deleted, then 
recreated somehow.  There are no detours in the following code.

I added a lot of waits because sometimes that fixes weird problems. 
To no avail this time.


repeat with x = 1 to the number of cds of stack prefStack
         set the cantDelete of cd x of stack prefStack to false
       end repeat
       if "UserPrefs" is in the stacksInUse then
         stop using stack "UserPrefs"
         delete stack "UserPrefs"
       end if
       if "UserPrefs" is in the openstacks then
         close stack "UserPrefs"
         delete stack "UserPrefs"
       end if
       wait 10 ticks # giving it a chance to fully finish
       delete file prefStack
       wait 30 ticks # giving it a chance to fully finish
       answer "File deleted" # so that I can verify in the Prefs folder
	# that the file is actually deleted
       put decompress(the stackData of stack myAppStack) into s
       put s into url ("binfile:" & prefStack)
       save stack prefStack
       wait 5 ticks # giving it a chance to finish
       answer the xVersion of stack prefStack # gives the xVersion of 
the deleted stack,
# if I quit everything then open what should be the newly created stack,
# it is the same as the deleted stack, the new version never appears.

# here is where I tried to add revert
       revert stack dataPath
       answer the xVersion of stack dataPath
# the entire app failed to appear when I added revert, it's as though 
it just silently quit
# I never got an answer, nor a single window to appear, the app did 
not appear in stacksInUse or openStacks
-- 
WlND0WS and MAClNT0SH shareware games
BIackjack GoId
http://www.gypsyware.com



More information about the use-livecode mailing list