[vtkusers] Re: Error msg when destroying a vtkTkRenderWidget
Roger Blum
roger_blum at swissonline.ch
Wed Jun 14 20:45:29 EDT 2006
Hi Goodwin,
Thanks for this hint. Clicking the destroy button is fine.
Roger
"Goodwin Lawlor" <goodwin.lawlor at ucd.ie> schrieb im Newsbeitrag
news:e6pd0g$as$1 at sea.gmane.org...
> Roger Blum wrote:
>> Thanks a lot for your answer. It was in fact the interactor which was not
>> deleted and caused the warning.
>>
>> Thanks for the sample code for handling the closing of a window and
>> dealing with vtk error messages / warnings, too.
>> This helps me a lot.
>>
>> Roger
>
> Hi Roger,
>
> Actually, looking at the code again... pressing "e" causes a crash. It
> happens when the ExitEvent is invoked but iren's "this->Start" points to
> an observer that has been deleted. I haven't got time to find out what's
> going on. Maybe someone will pick it up again in the future.
>
> Clicking the destroy button in the title bar works ok though.
>
> Goodwin
>
>
>> "Goodwin Lawlor" <goodwin.lawlor at ucd.ie> schrieb im Newsbeitrag
>> news:e6mn20$vt0$1 at sea.gmane.org...
>>> Roger Blum wrote:
>>>> Hi vtk users,
>>>>
>>>> I have an application written in Tcl which displays a scene of
>>>> different actors. The user can select one actor to display in a
>>>> separate window.
>>>> To acheive this I create a new toplevel widget with an embedded
>>>> vtkTkRenderWidget. I create a new mapper (as a shallow copy of the
>>>> original mapper) and a new actor, which I add to the new renderer.
>>>>
>>>> When I close this separate window the following warning is displayed:
>>>> Generic Warning: In
>>>> C:\Dashboards\Releases\rc-VTK-5-0-0-rc1\VTK\Rendering\vtkTkRenderWidget.cxx,
>>>> line 622
>>>> A TkRenderWidget is being destroyed before it associated
>>>> vtkRenderWindow is destroyed. This is very bad and usually due to the
>>>> order in which objects are being destroyed. Always destroy the
>>>> vtkRenderWindow before destroying the user interface components.
>>>>
>>>> How do I have to destroy/delete the vtk objects created for this
>>>> separate window? I do not create a vtkRenderWindow explicitly. It is
>>>> created by the vtkTkRenderWidget. I have tried to delete/destroy the
>>>> objects in various sequences, nothing helped. A call to
>>>> [tkRenderWidget GetRenderWindow] Delete
>>>> caused error messages complaining about a non existing TempXYZ object.
>>> In short, you have to delete the interactor too (which is created for
>>> you, if needed). Here's some code to destroy the window, either by
>>> clicking the destroy button in the title bar or pressing "e".
>>>
>>> package require vtk
>>> package require vtkinteraction
>>>
>>> #console show
>>> wm withdraw .
>>>
>>> toplevel .w
>>>
>>> vtkTkRenderWidget .w.renWidget
>>>
>>> ::vtk::bind_tk_render_widget .w.renWidget
>>>
>>> pack .w.renWidget -expand 1 -fill both
>>>
>>> set renWin [.w.renWidget GetRenderWindow]
>>>
>>> vtkRenderer ren
>>> $renWin AddRenderer ren
>>>
>>> wm protocol .w WM_DELETE_WINDOW cbCloseWindow
>>>
>>> set iren [$renWin GetInteractor]
>>> # remove the default callback to exit the app
>>> $iren RemoveObserver [::vtk::get_widget_variable_value $iren
>>> ExitEventTag]
>>> $iren AddObserver ExitEvent cbCloseWindow
>>>
>>> proc cbCloseWindow {} {
>>> set renWin [.w.renWidget GetRenderWindow]
>>>
>>> set renCol [$renWin GetRenderers]
>>> for {$renCol InitTraversal} {[set ren [$renCol GetNextItem]] ne ""} {}
>>> {
>>> $renWin RemoveRenderer $ren
>>> $ren Delete
>>> }
>>>
>>> set iren [$renWin GetInteractor]
>>> $renWin Delete
>>> $iren Delete
>>> destroy .w
>>> }
>>>
>>>> As a quick and dirty solution: Can I prevent vtk from showing the
>>>> vtkOutputWindow?
>>> You can direct the error messages to a file using vtkFileOutputWindow
>>> (eg)
>>>
>>> vtkFileOutputWindow outputFile
>>> outputFile SetFileName errors.log
>>> outputFile SetInstance outputFile
>>>
>>> or just switch them off:
>>>
>>> vtkObject obj
>>> obj GlobalWarningDisplayOff
>>> obj Delete
>
>
> _______________________________________________
> This is the private VTK discussion list. Please keep messages on-topic.
> Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list