[vtkusers] Trouble with QVTK and X11 Garbage Collection

Clinton Stimpson clinton at elemtech.com
Thu Apr 6 11:04:32 EDT 2006


>From: Chris Hahn <chahn at ucalgary.ca>
>Subject: [vtkusers] Trouble with QVTK and X11 Garbage Collection
>To: vtkusers at vtk.org
>
>Hi
>
>I'm having a little trouble deleting a Qt window which contains a QVTK 
>widget. The code that I'm using to display and use this QVTK widget is 
>based off of one of the examples online and basically goes like this:
>
>...
>     qVTK1->SetRenderWindow(theViewer->GetRenderWindow());
>     theViewer->SetupInteractor(qVTK1->GetRenderWindow()->GetInteractor());
>     qVTK1->show();
>...
>
>Where 'theViewer' is a vtk object of type vtkImageViewer. My destructor 
>for this window is as follows:
>
>...
>    if(theViewer != NULL)
>        theViewer->Delete();
>    destroy(); //destroys the Qt window
>...
>
>My problem is if I try to delete the window using this destructor I get 
>the following error message:
>
>X Error: BadValue (integer parameter out of range for operation) 2
>  Extension:    145 (Uknown extension)
>  Minor opcode: 9 (Unknown request)
>  Resource id:  0x2a0010f
>X Error: BadValue (integer parameter out of range for operation) 2
>  Extension:    145 (Uknown extension)
>  Minor opcode: 9 (Unknown request)
>  Resource id:  0x2a00117
>
>And then the program seg faults. Now, if I set the QVTK widget's render 
>window to NULL in the destructor, then I can delete the Qt window with 
>no problem. However, if I try to create a new window of the same type as 
>I just deleted, I get another segmentation fault. This segmentation 
>fault occurs right after the call to 
>qVTK1->SetRenderWindow(theViewer->GetRenderWindow()) and when I traced 
>it using insight, it supposedly happened in 
>__driGarbageCollectDrawables, which I believe is related to the X11 
>driver for my video card.
>
>So my question is does anyone know if this is a driver issue or am I 
>doing something wrong with QVTK?
>  
>
Without having more code, I'm guessing what you are doing...
So it looks like you are deriving in QVTKWidget, and calling the 
protected destroy() in your destructor, which is like pulling the rug 
out from under vtkRenderWindow, resulting in those X11 errors you are 
getting.  Setting the RenderWindow to NULL cleans things up making it 
safe to call destroy() afterwards.
Or possibly better, just don't call destroy() at all.  If you let the 
destructors do cleanup in their normal order, QVTKWidget will clean up 
the render window, and QWidget will destroy the window.

Clint




More information about the vtkusers mailing list