Dalibor Sramek wrote:
> I have just spent couple of hours tracking an error causing my application to
> segfault.
>
> Finally I have found following construction in my code:
>
> @widget.handle(@widget, MKUINT(Widget::ID_SEL_COPY, SEL_COMMAND), nil)
>
> The sender (first argument) is the same object that should receive the message.
> After replacing sender with "self" the error (which demonstrated itself in
> completely unrelated part of code) went away.
>
> I just want to be sure it was the reason. The receiver does not suppose the
> message sender to be itself, right?
When you send a FOX message by calling the handle() method, the receiver
of that message is the object on which you call handle(). The 'sender'
argument is a reference to the object that is sending the message. With
FOX, messages are bidirectional and it is common to see one FOX object
"A" send a message to "B":
B.handle(A, ..., ...)
only to have the receiver (B) turn around and send a message back to the
sender:
def onHandleMessageFromA(sender, sel, ptr)
sender.handle(self, ..., ...)
end
Given this, it wouldn't usually make sense for the sender of the message
to be the same object as the receiver, although that's not specifically
forbidden. Regardless, I want to avoid any potential bugs in FXRuby that
cause the Ruby interpreter to seg fault, so if you can file a bug report
about how to reproduce the crash that would be great.
Hope this helps,
Lyle
|