I am having a hard time with a central piece of Haiku’s magic and I want to get this right.
It seems the message distribution among BHandler’s is not working as documented, and I could not find out why so far (will inspect the source next).
I have a central BApplication process and want to handover domain specific messages to application “services” implemented as BHandler processes. This seems like a nice and natural architecture for a Haiku application, and should work according to the docs, like this:
- in your Application, add the Handlers via
AddHandler(I can see this works by checking
- in the Application’s
MessageReceived, pass on any message you don’t (want to) handle centrally to the superclass via
BApplication::MessageReceived(or should it be
BLooper? tried all to no avail)
- the base class should then call the next handler in the chain, until one either accepts the message, or, after the last one is called, drop it eventually.
In my case, the message is silently dropped before reaching any of the attached Handlers.
I can only see it’s accepted in the main Application thread, but then it’s lost.
What frightens me is that even the test included in Haiku sources (HandlerLooperMessageTest.cpp) does not work as advertised and shows the same symptoms (I’ve added logging to see which is called, Handler or Looper, and then extended the test to send 2 different messages, where one should reach the Looper, and the other should reach a Handler).
Is this really a bug in one of the centerpieces of Haiku? Seems unlikely, since message passing and forwarding seems to work for Windows and their attached controls. But then the test should also work…