[vtkusers] QVTKWidget threading problem?

Ashika Umanga Umagiliya aumanga at biggjapan.com
Thu Sep 2 04:33:28 EDT 2010


Greetings all,

As shown in the following code-snippets,  I create an instance of QVTWidget
inside 'RzVTKViewerWorkspaceViewer' class.
This 'RzVTKViewerWorkspace' instance behaves as the  centralWidget for a
QMainWindow instance.

When I run my application and open above widget ,first it gives the warning:

"QObject: Cannot create children for a parent that is in a different thread.
(Parent is QObject(0x112f5e68), parent's thread is QThread(0xb438a0),
current thread is QThread(0x112fedc0)"


And I can see the rendered spear and i can resize the window without errors.
But when I perform any mouse action (drag,click..etc) program crashes.
I have given the debug info below.

Does 'QVTWidget' create a new thread for VTK related processing ?
I dont create any threads in my application,but I create several QMainWindow
instances.

Any tips on this?

----------------------RzVTKViewerWorkspaceView.h--------------------------------------------------

class RzVTKViewerWorkspaceView :public QWidget,public IRzWorkspaceView {
private:
QVTKWidget *qtWidget;
public:
RzVTKViewerWorkspaceView(QWidget *parent=0);
virtual ~RzVTKViewerWorkspaceView();

void registerWindowMenu();
//unregister menu/toolbar related to the workspace view
void unregisterWindowMenu();
//initialization methods
void init();
};



-----------------------------RzVTKViewerWorkspaceView.cpp------------------------------------------

RzVTKViewerWorkspaceView::RzVTKViewerWorkspaceView(QWidget *parent) :
QWidget(parent), IRzWorkspaceView((MainWindow*) parent) {
qDebug("constructing VTKWorkspace View");
setCurrentStateMachine(NULL);

             //init() method is called after instansiating object

}

RzVTKViewerWorkspaceView::~RzVTKViewerWorkspaceView() {
}

void RzVTKViewerWorkspaceView::registerWindowMenu() {

}

void RzVTKViewerWorkspaceView::unregisterWindowMenu() {

}

void RzVTKViewerWorkspaceView::init() {
qtWidget = new QVTKWidget(this);
qtWidget->resize(512, 512);

//SETUP VTK
vtkSmartPointer<vtkSphereSource> sphereSource = vtkSmartPointer<
vtkSphereSource>::New();
sphereSource->Update();
vtkSmartPointer<vtkPolyDataMapper> sphereMapper = vtkSmartPointer<
vtkPolyDataMapper>::New();
sphereMapper->SetInputConnection(sphereSource->GetOutputPort());
vtkSmartPointer<vtkActor> sphereActor = vtkSmartPointer<vtkActor>::New();
sphereActor->SetMapper(sphereMapper);

// VTK Renderer
vtkSmartPointer<vtkRenderer> leftRenderer =
vtkSmartPointer<vtkRenderer>::New();
leftRenderer->AddActor(sphereActor);

qtWidget->GetRenderWindow()->AddRenderer(leftRenderer);

QVBoxLayout *vboxLayout = new QVBoxLayout;

vboxLayout->addWidget(qtWidget);

setLayout(vboxLayout);
}




-------------------------------Debug
Info-------------------------------------------------------------------


#Program received signal SIGSEGV, Segmentation fault.
0x02c14c41 in QRegion::isEmpty (this=0x28d490) at painting\qregion.cpp:3975
3975    painting\qregion.cpp: No such file or directory.        in
painting\qregion.cpp
(gdb) back
#0  0x02c14c41 in QRegion::isEmpty (this=0x28d490)
    at painting\qregion.cpp:3975
#1  0x02aff18a in QWidgetPrivate::childAt_helper (this=0x11349000, p=...,
 ignoreChildrenInDestructor=false) at kernel\qwidget.cpp:9641
#2  0x02aff109 in QWidgetPrivate::childAt_helper (this=0xd0180b8, p=...,
 ignoreChildrenInDestructor=false) at kernel\qwidget.cpp:9636
#3  0x02afef9e in QWidget::childAt (this=0xb4df00, p=...)    at
kernel\qwidget.cpp:9600
#4  0x02b17bb6 in QETWidget::translateMouseEvent (this=0x113492e8, msg=...)
   at kernel\qapplication_win.cpp:3114
#5  0x02b134db in QtWndProc at 16 (hwnd=0x260bc8, message=513, wParam=1,
 lParam=17367304) at kernel\qapplication_win.cpp:1629
#6  0x76666238 in USER32!IsDialogMessageW ()   from
C:\Windows\syswow64\user32.dll
#7  0x00260bc8 in ?? ()warning: (Internal error: pc 0x200 in read in
psymtab, but not in symtab.)
warning: (Internal error: pc 0x200 in read in psymtab, but not in symtab.)

#8  0x00000201 in ?? (warning: (Internal error: pc 0x200 in read in psymtab,
but not in symtab.)

)
    at ../../include/QtCore/../../src/corelib/tools/qvector.h:490
warning: (Internal error: pc 0x200 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x0 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x0 in read in psymtab, but not in symtab.)

#9  0x00000001 in ?? (warning: (Internal error: pc 0x0 in read in psymtab,
but n
ot in symtab.)

)
    at ../../../../include/QtCore/../../src/corelib/tools/qstring.h:869
warning: (Internal error: pc 0x0 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x0 in read in psymtab, but not in symtab.)

#10 0x02b12ab3 in qt_is_translatable_mouse_event (message=1166667845)
    at kernel\qapplication_win.cpp:1401
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100902/e4c4ab25/attachment.htm>


More information about the vtkusers mailing list