A new version of Morphic was added to project The Inbox:
http://source.squeak.org/inbox/Morphic-ct.1541.mcz==================== Summary ====================
Name: Morphic-ct.1541
Author: ct
Time: 23 September 2019, 7:20:12.900577 pm
UUID: 5662f3d6-138a-3f4a-82e1-3fada9c32f37
Ancestors: Morphic-ct.1540
Revise changes from ancestor: Provide as utility instead of preference, only store MethodReferences, optimization
Thanks to Marcel :)
=============== Diff against Morphic-ct.1540 ===============
Item was changed:
+ ----- Method: Morph class>>rememberProvenance (in category 'misc') -----
- ----- Method: Morph class>>rememberProvenance (in category 'preferences') -----
rememberProvenance
- <preference: 'Remember provenance of each morph'
- categoryList: #(Morphic)
- description: 'If enabled, each morph will contain a debug item to view its creator stack. This allows you to explore its provenance later. May affect performance.'
- type: #Boolean>
^ RememberProvenance ifNil: [false]!
Item was removed:
- ----- Method: Morph class>>rememberProvenance: (in category 'preferences') -----
- rememberProvenance: aBoolean
-
- RememberProvenance := aBoolean.!
Item was added:
+ ----- Method: Morph class>>rememberProvenanceDuring: (in category 'misc') -----
+ rememberProvenanceDuring: aBlock
+ "self rememberProvenanceDuring: [self inform: 'Test']"
+
+ | wasRemembering |
+ wasRemembering := RememberProvenance.
+ [RememberProvenance := true.
+ ^ aBlock value]
+ ensure: [RememberProvenance := wasRemembering].!
Item was changed:
----- Method: Morph>>initialize (in category 'initialization') -----
initialize
"initialize the state of the receiver"
owner := nil.
submorphs := Array empty.
bounds := self defaultBounds.
color := self defaultColor.
self class rememberProvenance ifTrue: [
+ | creatorStack officialCreator |
+ creatorStack := OrderedCollection new.
+ officialCreator := nil.
+ thisContext home stack do: [:context |
+ creatorStack add: context method methodReference.
+ (officialCreator isNil and: [context method hasPragma: #example])
+ ifTrue: [officialCreator := creatorStack last]].
- | creatorStack |
- creatorStack := thisContext home stack collect: #method.
self setProperty: #creatorStack toValue: creatorStack.
+ officialCreator ifNotNil: [
+ self setProperty: #officialCreator toValue: officialCreator]].!
- creatorStack
- detect: [:method | method hasPragma: #example]
- ifFound: [:method | self setProperty: #officialCreator toValue: method]].!