[squeak-dev] The Trunk: Morphic-mt.1485.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Apr 24 09:11:03 UTC 2019

Marcel Taeumel uploaded a new version of Morphic to project The Trunk:

==================== Summary ====================

Name: Morphic-mt.1485
Author: mt
Time: 24 April 2019, 11:10:53.74187 am
UUID: ddfc0442-d803-f04f-9267-a248ef94916e
Ancestors: Morphic-cmm.1484

Fixes a minor update/performance issue in SketchMorph, which affects the buttons of system windows.

I *think* it is never a good idea to overwrite #layoutChanged with such side effects. There are other examples in the code base. We should refactor that in the (near) future.

WHY? The message #layoutChanged should mean "Hey! My bounds have changed. Consider this in the next layout computation." It should not *do* the actual change but only tell others about it *after* it has happened.

=============== Diff against Morphic-cmm.1484 ===============

Item was changed:
  ----- Method: SketchMorph>>layoutChanged (in category 'layout') -----
  	"Update rotatedForm and compute new bounds."
+ 	| priorBounds |
+ 	fullBounds ifNotNil: [self changed].
+ 	priorBounds := bounds.
+ 	self flag: #refactor. "mt: Such side-effects in #layoutChanged can have a severe impact on performance. Better not overwrite it but manage the rotatedForm elsewhere and from there call #layoutChanged if bounds change. Also, just overwrite #extent to use the extent of the rotated form."
- 	self changed.
  	self generateRotatedForm.
  	bounds := bounds origin extent: rotatedForm extent.
+ 	priorBounds ~= bounds
+ 		ifTrue: [super layoutChanged].
- 	super layoutChanged.
  	self changed.

More information about the Squeak-dev mailing list