Levente Uzonyi uploaded a new version of EToys to project The Trunk: http://source.squeak.org/trunk/EToys-ul.295.mcz
==================== Summary ====================
Name: EToys-ul.295 Author: ul Time: 24 April 2017, 7:10:16.712957 pm UUID: c7efa44d-562c-4e3a-82c9-aa6c5e17645c Ancestors: EToys-ul.294
KedamaMorph changes: - turtlesToDisplay is a Set instead of an Array (instances are migrated by the postscript) - turtleCount is counted lazily by #turtleCount - therefore #calcTurtlesCount is gone; senders set turtleCount to nil instead - #delete can not blow up anymore, because the keys of the dictionary are copied before mass deletion
=============== Diff against EToys-ul.294 ===============
Item was changed: ----- Method: KedamaMorph>>addToTurtleDisplayList: (in category 'setup') ----- addToTurtleDisplayList: p
- | a | (p isKindOf: KedamaExamplerPlayer) ifFalse: [^ self]. + turtlesToDisplay add: p! - a := turtlesToDisplay copyWithout: p. - turtlesToDisplay := a copyWith: p. - !
Item was removed: - ----- Method: KedamaMorph>>calcTurtlesCount (in category 'turtles') ----- - calcTurtlesCount - - turtleCount := turtlesDict detectSum: [ :each | each size ]!
Item was changed: ----- Method: KedamaMorph>>clearAll (in category 'setup') ----- clearAll "Reset this StarSqueak world. All patch variables are cleared, all turtles are removed, and all demons are turned off."
patchVarDisplayForm := Form extent: dimensions depth: 32. self initializePatch. self recreateMagnifiedDisplayForm. self initializeTurtlesDict.
+ turtleCount := nil. - turtleCount := 0. lastTurtleID := 0.
self color: Color black.
!
Item was changed: ----- Method: KedamaMorph>>delete (in category 'deleting') ----- delete
- | c | super delete. + turtlesDict keys do: [:key | + self deleteAllTurtlesOfExampler: key. + key costume ifNotNil: [ :costume | + costume renderedMorph delete ] ]. + defaultPatch ifNotNil: [ defaultPatch delete ] - turtlesDict keysDo: [:k | - self deleteAllTurtlesOfExampler: k. - c := k costume. - c ifNotNil: [c renderedMorph delete]. - ]. - - defaultPatch ifNotNil: [defaultPatch delete]. !
Item was changed: ----- Method: KedamaMorph>>deleteAllTurtlesOfExampler: (in category 'turtles') ----- deleteAllTurtlesOfExampler: examplerPlayer
turtlesDict removeKey: examplerPlayer ifAbsent: []. self removeFromTurtleDisplayList: examplerPlayer. + turtleCount := nil - self calcTurtlesCount. !
Item was changed: ----- Method: KedamaMorph>>deleteTurtleID:of: (in category 'turtles') ----- deleteTurtleID: who of: examplerPlayer "Delete the given turtle from this world."
| array | array := examplerPlayer turtles. array ifNil: [^ self]. turtlesDictSemaphore critical: [ array deleteTurtleID: who. ]. + turtleCount := nil. - self calcTurtlesCount. examplerPlayer costume renderedMorph privateTurtleCount: array size. "examplerPlayer allOpenViewers do: [:v | v resetWhoIfNecessary]." !
Item was changed: ----- Method: KedamaMorph>>initializeTurtlesDict (in category 'initialization') ----- initializeTurtlesDict
turtlesDict := IdentityDictionary new. + turtlesToDisplay := Set new. - turtlesToDisplay := Array new. !
Item was changed: ----- Method: KedamaMorph>>makeReplicatedTurtles:examplerPlayer:color:ofPrototype:randomize: (in category 'turtles') ----- makeReplicatedTurtles: count examplerPlayer: tp color: c ofPrototype: prototype randomize: randomizeFlag
| array inst | array := tp turtles.
inst := prototype ifNil: [self makePrototypeOfExampler: tp color: c].
turtlesDictSemaphore critical: [ array addTurtlesCount: count ofPrototype: inst for: self randomize: randomizeFlag. ]. + turtleCount := nil. - self calcTurtlesCount. self changed. !
Item was changed: ----- Method: KedamaMorph>>makeTurtles:examplerPlayer:color:ofPrototype:turtles:randomize: (in category 'turtles') ----- makeTurtles: count examplerPlayer: tp color: c ofPrototype: prototype turtles: turtles randomize: randomizeFlag
| array inst | array := tp turtles. (turtlesDict includesKey: tp) ifFalse: [ self addToTurtleDisplayList: tp. turtlesDict at: tp put: (array := turtles). ].
inst := prototype ifNil: [self makePrototypeOfExampler: tp color: c].
turtlesDictSemaphore critical: [array setTurtlesCount: count prototype: inst for: self randomize: randomizeFlag]. + turtleCount := nil. - self calcTurtlesCount. self changed. !
Item was changed: ----- Method: KedamaMorph>>makeTurtlesAtPositionsIn:examplerPlayer:ofPrototype: (in category 'turtles') ----- makeTurtlesAtPositionsIn: positionAndColorArray examplerPlayer: tp ofPrototype: prototype
| array inst | array := tp turtles.
inst := prototype ifNil: [self makePrototypeOfExampler: tp].
turtlesDictSemaphore critical: [array addTurtlesCount: positionAndColorArray first size ofPrototype: inst for: self positionAndColorArray: positionAndColorArray]. + turtleCount := nil. - self calcTurtlesCount. self changed. !
Item was changed: ----- Method: KedamaMorph>>removeAllFromTurtleDisplayList (in category 'drawing') ----- removeAllFromTurtleDisplayList
+ turtlesToDisplay removeAll - turtlesToDisplay := #(). !
Item was changed: ----- Method: KedamaMorph>>removeFromTurtleDisplayList: (in category 'turtles') ----- removeFromTurtleDisplayList: examplerPlayer
+ turtlesToDisplay remove: examplerPlayer ifAbsent: nil - turtlesToDisplay := turtlesToDisplay copyWithout: examplerPlayer. !
Item was changed: ----- Method: KedamaMorph>>setTurtlesCount:examplerPlayer:color: (in category 'turtles') ----- setTurtlesCount: count examplerPlayer: tp color: cPixel
| prototype | prototype := self makePrototypeOfExampler: tp color: cPixel. turtlesDictSemaphore critical: [(tp turtles) setTurtlesCount: count prototype: prototype for: self randomize: true]. + turtleCount := nil - self calcTurtlesCount. !
Item was changed: ----- Method: KedamaMorph>>turtleCount (in category 'etoys') ----- turtleCount
+ ^turtleCount ifNil: [ + turtleCount := turtlesDict detectSum: [ :each | each size ] ] - ^ turtleCount. !
Item was changed: + (PackageInfo named: 'EToys') postscript: 'KedamaMorph allInstancesDo: [ :each | + (each instVarNamed: #turtlesToDisplay) ifNotNil: [ :turtlesToDisplay | + turtlesToDisplay class == Array ifTrue: [ + each instVarNamed: #turtlesToDisplay put: turtlesToDisplay asSet ] ] ]'! - (PackageInfo named: 'EToys') postscript: '"Remove an obsolete class that somehow got into the system" - (Smalltalk environment includesKey: #KedamaTurtleVectorPlayer) ifTrue: [ - Smalltalk environment removeKey: #KedamaTurtleVectorPlayer. - SystemOrganization removeMissingClasses]. - - "Clear weak message sends to remove modal windows from worlds that are closing." - (WeakMessageSend allInstances select: [:wm | - (wm receiver isKindOf: PasteUpMorph) and: [wm selector = #removeModalWindow]]) - do: [:wm | wm receiver: nil].'!
packages@lists.squeakfoundation.org