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

David Gobbi david.gobbi at gmail.com
Fri Feb 19 16:16:04 EST 2010


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.

Yeah, I just took a look at the CocoaInteractor code for closing the
window.  It's a bit difficult to trace through 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];
}


   David


On Fri, Feb 19, 2010 at 2:04 PM, Sean McBride <sean at rogue-research.com> wrote:
> On 2/19/10 1:08 PM, David Gobbi said:
>
>>I have a question for the Cocoa developers out there.  The
>>vtkCocoaRenderWindow never calls "close" on the NSWindow.  All the
>>other platform-specific vtkRenderWindow implementations close their
>>window in their DestroyWindow() method, but not vtkCocoaRenderWindow.
>>Is there a reason for this?
>>
>>I'm looking for a way to close the window, but the only ways that I
>>can find are to (1) press the "close" button in the title bar or (2)
>>terminate the application.
>
> There's code in vtkCocoaRenderWindowInteractor that closes the window.
> It's all pretty hairy I'm afraid.
>
> Perhaps DestroyWindow should be closing it as well...
>
> --
> ____________________________________________________________
> 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