debugging when:send:to: ?

Ned Konz ned at bike-nomad.com
Tue Jul 8 22:47:44 UTC 2003


On Tuesday 08 July 2003 03:25 pm, Ingo Hohmann wrote:

> I have an app set up with some when:send:to: messages, now after
> some working on the code one of the messages is not sent any more,
> the method setting up the when:send:to: is, though.
>
> What do I do to debug this? I've set some halt's in, so I know that
> my method isn't called, I've stepped through triggerEvent, and have
> seen that my method isn't called, I've double checked message names
> (had some fun with a missing colon before ;-)
>
> So, any more ideas?

Yes:

If the argument or recipient of one of those messages got garbage collected,
the message won't get sent.

You can test for this.

So you can do this:
-------------
Assume you have this pattern:

recipient when: #someEvent send: #someSelector to: performer with: arguments.

Now you can do this (I did the following lines in a Workspace):

recipient actionMap 

recipient _ Object new.
performer _ Object new.

recipient when: #someEvent send: #inspect to: performer.

recipient triggerEvent: #someEvent.	"works OK"

recipient actionSequenceForEvent: #someEvent  " #(WeakMessageSend(#inspect -> an Object))"
(recipient actionSequenceForEvent: #someEvent) isReceiverOrAnyArgumentGarbage "false"

recipient updateableActionMap " an IdentityDictionary(#someEvent->WeakMessageSend(#inspect -> an Object) )"

performer _ nil.
Smalltalk garbageCollect.

recipient updateableActionMap	" an IdentityDictionary(#someEvent->WeakMessageSend(#inspect -> nil) )"

(recipient actionSequenceForEvent: #someEvent) isReceiverOrAnyArgumentGarbage " true"

-------------

This also happens when any arguments get garbage collected.

To avoid this happening, you can be explicit with your registrations:

recipient when: #someEvent evaluate: (MessageSend
            receiver: performer
            selector: #someAction)

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE



More information about the Squeak-dev mailing list