Am 05.12.2010 um 12:09 schrieb Stephan Assmus: > Hi, > >> 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. > > If you use the BWindow pointer for anything else than sending a message, you > are right. However, sending a message involves (no matter which way you do > it) to lock the global BLooper list and to check if the looper is still valid > before accessing any stale pointer. It's a kind of magic ;) Thanks for the clarification. AFAICT this is not documented in the BeBook. Bye, Michael