[haiku-3rdparty-dev] Re: Problem sending/receiving app defined msgs

  • From: Michael Pfeiffer <michael.w.pfeiffer@xxxxxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Sun, 5 Dec 2010 07:41:47 +0100

Am 04.12.2010 um 23:52 schrieb Axel Dörfler:

> hudsonco1@xxxxxxx wrote:
>> Thanks, I used be_app->WindowAt(0), which works because there is only
>> one window.
> 
> The scripting solution is only for windows in other teams (that's what 
> probably everyone assumed looking at your snippet). If you are in the 
> same address space, you usually know your window, be it either because 
> you remember its pointer on creation or, as you did, just use 
> BApplication::WindowAt(). So that solution is perfectly fine, just the 
> rest of the code looks then pretty complicated :-)

Unless this has changed in Haiku, using WindowAt() is not thread-safe.
The returned BWindow object could already have been deleted when you
try to access it.
So it is (was at least in BeOS) recommended to use a BMessenger even
in the same application, because it checks if the target is still
valid before sending a message.

Bye,
Michael

Other related posts: