[vtk-developers] Missing [window close] in vtkCocoaRenderWindow

Sean McBride sean at rogue-research.com
Wed Feb 24 09:58:00 EST 2010


On 2/19/10 2:16 PM, David Gobbi said:

>I wonder if there is any harm in calling "close" multiple times?  I've
>added a [window close] to DestroyWindow and so far everything seems to
>be peachy keen, the window disappears when Finalize() or Delete() is
>called just like with the other platforms.  As long as this won't
>adversely effect anyone, I'd like to commit it.

I'll make the same change in my working copy and give it a try... Do you
mind holding off on the commit for a couple of days?

>Yeah, I just took a look at the CocoaInteractor code for closing the
>window.  It's a bit difficult to trace through

It is. :(

> but it looks
>suspicious, e.g. the following code could very easily dereference a
>null pointer:
>
>- (void)stop
>{
>  // Retrieve the NSWindow.
>  NSWindow  *win = nil;
>  if (renWin != NULL)
>    {
>    win = reinterpret_cast<NSWindow *>(renWin->GetRootWindow());
>    }
>
>  // Close the window, removing it from the screen and releasing it
>  [win close];
>}

Either I need more coffee or you have forgotten that messaging nil in
Obj-C is a nop.

Cheers,

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada





More information about the vtk-developers mailing list