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

commits at source.squeak.org commits at source.squeak.org
Thu Sep 10 12:41:24 UTC 2015


Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1005.mcz

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

Name: Morphic-mt.1005
Author: mt
Time: 10 September 2015, 2:40:42.838 pm
UUID: d77f85b5-c861-d347-93c6-fb0bce9283b9
Ancestors: Morphic-mt.1004

Fixes a memory leak that occurs when handling drop events and an error occurs.

Primarily, this is related to step messages holding strong references to their receivers. Stepping will only stop if #delete is called on a morph.

=============== Diff against Morphic-mt.1004 ===============

Item was changed:
  ----- Method: HandMorph>>dropMorph:event: (in category 'grabbing/dropping') -----
  dropMorph: aMorph event: anEvent
  	"Drop the given morph which was carried by the hand"
  	| event dropped |
  	(anEvent isMouseUp and:[aMorph shouldDropOnMouseUp not]) ifTrue:[^self].
  
  	"Note: For robustness in drag and drop handling we remove the morph BEFORE we drop him, but we keep his owner set to the hand. This prevents system lockups when there is a problem in drop handling (for example if there's an error in #wantsToBeDroppedInto:). THIS TECHNIQUE IS NOT RECOMMENDED FOR CASUAL USE."
  	self privateRemove: aMorph.
  	aMorph privateOwner: self.
  
  	dropped := aMorph.
  	(dropped hasProperty: #addedFlexAtGrab) 
  		ifTrue:[dropped := aMorph removeFlexShell].
  	event := DropEvent new setPosition: self position contents: dropped hand: self.
+ 	
+ 	[ "In case of an error, ensure that the morph-to-be-dropped will be disposed. Otherwise it may confuse garbage handler. See the sends of #privateRemove: and #privateOwner: above."
+ 		self sendEvent: event focus: nil.
+ 		event wasHandled ifFalse: [aMorph rejectDropMorphEvent: event] ]
+ 			ensure: [ aMorph owner == self ifTrue: [aMorph delete] ].
+ 	
- 	self sendEvent: event focus: nil.
- 	event wasHandled ifFalse:[aMorph rejectDropMorphEvent: event].
- 	aMorph owner == self ifTrue:[aMorph delete].
  	self mouseOverHandler processMouseOver: anEvent.!



More information about the Squeak-dev mailing list