[vtkusers] Close QVTKWidget crash

Clinton Stimpson clinton at elemtech.com
Wed Nov 30 09:57:02 EST 2011


On Wednesday, November 30, 2011 12:18:06 am Xavius wrote:
> Hi, guys!
> 
> I have a problem with QVTKWidget. My app has 4 QVTKWidget. When I double
> click one of them, it should stretch on the whole window, while others
> should be deleted (to release resources). But when I try to delete widgets
> - they crash somewhere in Remainder Loop of vtkObject::InvokeEvent(...)
> because of null pointer.
> The code I used id:
> in MyQVTKWidget:
> onLeftButtonPressed(...) {
>   QTime t = QTime::currentTime();
>   if (mTime.msecTo(t) < 200)
>     emit leftBnDblClicked();
>   mTime = t;
> }
> 
> in widget manager:
> onLeftBnDblClicked() {
>   if (!mWidgets.isEmpty()) {
>     qDeleteAll(mWidgets);
>     mWidgets.clear();
>   }
> 
>   MyQVTKWidget *widget = new MyQVTKWidget;
>   mWidgets.append(widget);
>   mLayout->addWidget(widget, 0, 0);
>   ...
> }
> 
> Please point me, what I'm doing wrong?

Maybe its because the deleted QVTKWidget is still in the call stack and needs 
to be used when unwinding the stack?

Try using deleteLater().  Or delete 3 and move 1 instead of deleting 4 and 
creating 1.

-- 
Clinton Stimpson
Elemental Technologies, Inc
Computational Simulation Software, LLC
www.csimsoft.com



More information about the vtkusers mailing list