The Inbox: Morphic-ct.1623.mcz

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

The Inbox: Morphic-ct.1623.mcz

commits-2
Christoph Thiede uploaded a new version of Morphic to project The Inbox:
http://source.squeak.org/inbox/Morphic-ct.1623.mcz

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

Name: Morphic-ct.1623
Author: ct
Time: 1 February 2020, 1:49:06.372633 pm
UUID: 2e64e67e-c69c-4041-a9cc-8925d9335986
Ancestors: Morphic-cmm.1618

Proposal: Add logic to remove all morphic alarms of a receiver

I like to use this method in #delete of custom Morph classes. It's often easier than looking up all senders of #addAlarm:* to find out the exact selectors of the alarms to remove ...

=============== Diff against Morphic-cmm.1618 ===============

Item was added:
+ ----- Method: Morph>>removeAlarms (in category 'events-alarms') -----
+ removeAlarms
+
+ self alarmScheduler ifNotNil: [:scheduler |
+ scheduler removeAlarmsFor: self].!

Item was added:
+ ----- Method: MorphicAlarmQueue>>removeAlarmsWithReceiver: (in category 'removing') -----
+ removeAlarmsWithReceiver: receiver
+
+ ^ heap removeAllSuchThat: [ :each | each receiver == receiver ]!

Item was added:
+ ----- Method: PasteUpMorph>>removeAlarmsFor: (in category 'alarms-scheduler') -----
+ removeAlarmsFor: aTarget
+ worldState removeAlarmsFor: aTarget!

Item was added:
+ ----- Method: WorldState>>removeAlarmsFor: (in category 'alarms') -----
+ removeAlarmsFor: aTarget
+ self lockAlarmsDuring: [:locked |
+ locked removeAlarmsWithReceiver: aTarget ]!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Morphic-ct.1623.mcz

Levente Uzonyi
On Sat, 1 Feb 2020, [hidden email] wrote:

> Christoph Thiede uploaded a new version of Morphic to project The Inbox:
> http://source.squeak.org/inbox/Morphic-ct.1623.mcz
>
> ==================== Summary ====================
>
> Name: Morphic-ct.1623
> Author: ct
> Time: 1 February 2020, 1:49:06.372633 pm
> UUID: 2e64e67e-c69c-4041-a9cc-8925d9335986
> Ancestors: Morphic-cmm.1618
>
> Proposal: Add logic to remove all morphic alarms of a receiver
>
> I like to use this method in #delete of custom Morph classes. It's often easier than looking up all senders of #addAlarm:* to find out the exact selectors of the alarms to remove ...
>
> =============== Diff against Morphic-cmm.1618 ===============
>
> Item was added:
> + ----- Method: Morph>>removeAlarms (in category 'events-alarms') -----
> + removeAlarms
> +
> + self alarmScheduler ifNotNil: [:scheduler |
> + scheduler removeAlarmsFor: self].!
>
> Item was added:
> + ----- Method: MorphicAlarmQueue>>removeAlarmsWithReceiver: (in category 'removing') -----
> + removeAlarmsWithReceiver: receiver
> +
> + ^ heap removeAllSuchThat: [ :each | each receiver == receiver ]!

heap is a Heap. #removeAllSuchThat: will use Collection's
implementation.
That implementation does not do what you expect it to do.
It will create a copy, and it will remove the elements from that copy, but
it will not modify the receiver.
Heap could implement #removeAllSuchThat: properly.
Even Collection could implement #removeAllSuchThat: properly using
#becomeForward:, but subclasses should still override that.
The question is: do we want to have Collection >> #removeAllSuchThat:
implemented?

Levente

>
> Item was added:
> + ----- Method: PasteUpMorph>>removeAlarmsFor: (in category 'alarms-scheduler') -----
> + removeAlarmsFor: aTarget
> + worldState removeAlarmsFor: aTarget!
>
> Item was added:
> + ----- Method: WorldState>>removeAlarmsFor: (in category 'alarms') -----
> + removeAlarmsFor: aTarget
> + self lockAlarmsDuring: [:locked |
> + locked removeAlarmsWithReceiver: aTarget ]!