[vtkusers] Trouble with QVTK and X11 Garbage Collection

Chris Hahn chahn at ucalgary.ca
Thu Apr 6 19:36:21 EDT 2006


Hi Clint

Thanks for the answer. Unfortunately I don't think I gave you quite 
enough information. The window I'm trying to delete is actually deriving 
QWidget while the QVTK widget is just one of a few widgets in the 
window. This is why I'm calling the destroy function: to get rid of the 
other widgets in the window. However, even if I don't call destroy(), I 
still get the same segmentation fault if I create a new window and then 
make the call to qVTK1->SetRenderWindow() in this new window.  
Everything runs fine as long as I don't make that call. I've also tried 
doing absolutely nothing in the destructor and this still gives me the 
same problem. Basically I'm at my wits end here...

In case it helps, I've attached the code for my window class, along with 
the Qt generated code for the user interface (ui_imagedisplaywindow.hh). 
Most of what matters should be in the constructor and destructor in 
ImageDisplayWindow.cc .

Thanks,
Chris

Clinton Stimpson wrote:

>
>> 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ImageDisplayWindow.cc
Type: text/x-c++src
Size: 8682 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060406/41b36ed6/attachment.cc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ImageDisplayWindow.hh
Type: text/x-c++hdr
Size: 2096 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060406/41b36ed6/attachment.hh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ui_imagedisplaywindow.hh
Type: text/x-c++hdr
Size: 1604 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060406/41b36ed6/attachment-0001.hh>


More information about the vtkusers mailing list