On 30.06.2011 02:41, Clemens wrote:
On Wed, 29 Jun 2011 08:19:44 +1200, Stephan Aßmus <superstippi@xxxxxx> wrote:completely avoid these headaches. On top of what Rene said, you can also safely invoke someBWindowPointer->PostMessage(), even if someBWindowPointer is stale and points to an already freed BWindow. This is some behind the scenes magic happening in PostMessage(), which prevents dereferencing stale BLooper pointers by means of looking it up in a list of valid BLoopers first. But let's not get distracted. If you stick to messaging like in my example code, you don't needI think Axel pointed it out already recently, the window could go away and a new window is allocated at the same pointer address, in this case the message will go to wrong window...
Technically true. However, I believe the application has to maintain a mapping between the "window" objects passed to the SDL event reporting functions, and the BWindows that represent them (the code I posted earlier includes a hint about this already). Since the application controls the life time of the BWindows in the first place, it just needs to keep the mapping up to date. In other words quitting a BWindow from the BApplication and removing the pointer from the map is an "atomic" operation. This way you can't actually have stale BWindow pointers.
Best regards, -Stephan