The Trunk: Morphic-tonyg.1687.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Morphic-tonyg.1687.mcz

commits-2
Tony Garnock-Jones uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-tonyg.1687.mcz

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

Name: Morphic-tonyg.1687
Author: tonyg
Time: 8 October 2020, 11:05:35.50804 am
UUID: 5f80a2cc-df45-4cd3-b083-cbe3daff637b
Ancestors: Morphic-eem.1686

Repair an error in Halo click handling that manifests with multiple transient hands.

Without this fix, you get an infinite recursion if:
        1. a Hand ('X') opens a halo on a Morph
        2. X disappears from the World
        3. a different Hand ('Y') clicks on the Morph associated with the Halo
       
The reason for the infinite recursion is that the code before this change assumes that "event hand halo", Y's halo, is the halo in question, but that is not true because X, the hand "holding" the halo, already left the world.

The change here makes Y, "event hand", adopt the halo before considering whether to discard the halo or not, so when it comes time, "event hand removeHalo" will do the right thing.

=============== Diff against Morphic-eem.1686 ===============

Item was changed:
  ----- Method: SimpleHaloMorph>>mouseDown: (in category 'events') -----
  mouseDown: event
  "Transfer the halo to the next likely recipient"
 
+ event hand obtainHalo: self.
+
  ((self containsPoint: event position) not or: [event blueButtonPressed not])
  ifTrue: [
  "Close this halo and give another morph the chance to react."
  event hand removeHalo.
  event resetHandlerFields.
  event hand world processEvent: event.
  ^ self].
 
+ self target ifNil: [
+ event hand removeHalo.
+ ^self].
- self target ifNil: [^self delete].
- event hand obtainHalo: self.
 
  self positionOffset: (event position - (self target point: self target position in: self owner)).
 
  "wait for drags or transfer"
  event hand
  waitForClicksOrDrag: self
  event: event
  selectors: { #transferHalo:. nil. nil. #startDragTarget:. }
  threshold: HandMorph dragThreshold.!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-tonyg.1687.mcz

marcel.taeumel
Thanks! Nice catch! :-)

Best,
Marcel

Am 08.10.2020 11:05:53 schrieb [hidden email] <[hidden email]>:

Tony Garnock-Jones uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-tonyg.1687.mcz

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

Name: Morphic-tonyg.1687
Author: tonyg
Time: 8 October 2020, 11:05:35.50804 am
UUID: 5f80a2cc-df45-4cd3-b083-cbe3daff637b
Ancestors: Morphic-eem.1686

Repair an error in Halo click handling that manifests with multiple transient hands.

Without this fix, you get an infinite recursion if:
1. a Hand ('X') opens a halo on a Morph
2. X disappears from the World
3. a different Hand ('Y') clicks on the Morph associated with the Halo

The reason for the infinite recursion is that the code before this change assumes that "event hand halo", Y's halo, is the halo in question, but that is not true because X, the hand "holding" the halo, already left the world.

The change here makes Y, "event hand", adopt the halo before considering whether to discard the halo or not, so when it comes time, "event hand removeHalo" will do the right thing.

=============== Diff against Morphic-eem.1686 ===============

Item was changed:
----- Method: SimpleHaloMorph>>mouseDown: (in category 'events') -----
mouseDown: event
"Transfer the halo to the next likely recipient"

+ event hand obtainHalo: self.
+
((self containsPoint: event position) not or: [event blueButtonPressed not])
ifTrue: [
"Close this halo and give another morph the chance to react."
event hand removeHalo.
event resetHandlerFields.
event hand world processEvent: event.
^ self].

+ self target ifNil: [
+ event hand removeHalo.
+ ^self].
- self target ifNil: [^self delete].
- event hand obtainHalo: self.

self positionOffset: (event position - (self target point: self target position in: self owner)).

"wait for drags or transfer"
event hand
waitForClicksOrDrag: self
event: event
selectors: { #transferHalo:. nil. nil. #startDragTarget:. }
threshold: HandMorph dragThreshold.!