Stack with the same name loop

Mark Waddingham mark at livecode.com
Thu Oct 7 10:38:18 EDT 2021


On 2021-10-07 15:26, Pi Digital via use-livecode wrote:
> Hi Mark (both :) )
> 
> Thanks for your explanation. Very thorough.
> 
> What I don’t understand is why the engine needs to delete the old
> reference (weak handle) when invoking a ‘save as’. Is it not just a
> matter of resaving you a new location and making the pointer to the
> storage device for that instance? Why does it need to save it and then
> remove from memory at all? Just carry on with what is already in
> memory without the need to reload. That’s why we use a ‘save as’
> anyway.

This isn't related to 'Save As' - nor is the engine doing anything here 
beyond sending a message - which is enforcing the 'only one main stack 
with a given (short) name exists in memory at any one time' invariant.

When a stack is deserialized from the on-disk file - before it is 
'hooked up' to anything (i.e. added to the list of things considered for 
any sort of search), it sweeps through all loaded mainStacks and checks 
to see if there is a name conflict (i.e. short name of new stack matches 
that of old).

If there is (and the filenames are different) then it deletes what it 
has just loaded and sends a 'reloadStack' message. Otherwise, it hooks 
the new loaded stack up to the internal list of things considered actual 
stacks.

The IDE handles the reloadStack message - it shows the dialog in 
question.

If you choose 'Cancel' it takes no action - so nothing changes (no new 
stack loaded, no old stack deleted).

If you choose 'Purge' the IDE does its best to remove the current stack 
in memory and *then* trys to load the new stack (from the different 
filepath) - as (in principal) there is no longer any stack in memory 
with the conflicting name, then engine loads it and things carry on.

If you choose 'Save' the IDE does the same as above except that *before* 
it tries to remove the current stack from memory, it saves (save as, if 
the current stack has no filename).

So the looping problem here lies somewhere in the process removing the 
existing stack from memory / saving it.

Warmest Regards,

Mark.

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps




More information about the use-livecode mailing list