Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 6b78943

Browse files
Merge pull request #1668 from livecode/bugfix-20041
[[ Bug 20041 ]] Update tags & wait array when a stack name changes
2 parents d473927 + 585ccc8 commit 6b78943

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

Toolset/palettes/tutorial/revtutorial.livecodescript

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,9 +1720,19 @@ on revInitialiseTutorial
17201720
revIDESetPreference "cToolbarIcons", true
17211721
revIDESetPreference "idePropertyInspector_labels", false
17221722

1723+
-- Ensure we know when stack names change
1724+
revIDESubscribe "ideNameChanged"
1725+
17231726
unlock screen
17241727
end revInitialiseTutorial
17251728

1729+
on ideNameChanged pOldName, pNewName, pTarget
1730+
if word 1 of pTarget is "stack" then
1731+
-- Update all our long IDs if we're tracking this stack
1732+
revTutorialStackNameChanged pOldName, pNewName
1733+
end if
1734+
end ideNameChanged
1735+
17261736
on revTutorialInitialiseStep
17271737
put false into sWaiting
17281738
put false into sIsInterlude
@@ -3401,6 +3411,30 @@ function revTutorialReparentChild pObject
34013411
return the long id of pObject
34023412
end revTutorialReparentChild
34033413

3414+
command revTutorialStackNameChanged pOldName, pNewName
3415+
-- Update the tagged objects
3416+
repeat for each key tType in sTaggedObjects
3417+
repeat for each key tTag in sTaggedObjects[tType]
3418+
replace "stack" && quote & pOldName & quote \
3419+
with "stack" && quote & pNewName & quote \
3420+
in sTaggedObjects[tType][tTag]
3421+
end repeat
3422+
end repeat
3423+
3424+
-- Update any wait state if we are waiting. Now that the tagged objects
3425+
-- are updated just call DoWait again with the current wait state.The
3426+
-- type/tag in the sWait array will resolve to the updated long ID
3427+
if sWait is not empty then
3428+
-- if new condition is immediately satisified (i.e. if we are waiting for a
3429+
-- stack name change) then sWaiting will still be false after revTutorialDoWait
3430+
put false into sWaiting
3431+
revTutorialDoWait sWait
3432+
if not sWaiting then
3433+
revTutorialWaitConditionSatisfied
3434+
end if
3435+
end if
3436+
end revTutorialStackNameChanged
3437+
34043438
# Take a tutorial tagged object (an array with 'type' and 'tag' keys)
34053439
# and return the corresponding long ID (or list of long IDs for 'set' types)
34063440
function revTutorialResolveObjectToLongID pTaggedObject, pUpdate

notes/bugfix-18915.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Allow a 'set the name of stack' step in interactive tutorials

notes/bugfix-20041.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Prevent tutorials breaking when stack name is changed

0 commit comments

Comments
 (0)