Greetings all,
This is going to be a long question,skip the [Background] if its not that neccasary ;)
[Background]
I am developing a modular QT based application.Application is extentible via QT based plugins. As shown in the figure, there are mainly 3 parts .(numbers in red)
1) libAppCore - the core of the application,which defines pluginterfaces,main UIS,interations..etc
2) App.exe - the applicatoin which implement some builtin plugins and main application execution.
3) Qt based plugins - several plugins which implements Plugin interfaces in libAppCore.dll
Here's how each components links each other:
libAppCore links QT libraries.
App.exe links libAppCore.DLL and QT libraries (App.exe uses someother QT Classes not being used my libAppCore.DLL)
Plugins (libAppQTPluginA.DLL , libAppQTPluginB.DLL ) - link libAppCore.DLL and QT libs. libAppQTPluginA.DLL - links OpenGL libAppQTPluginB.DLL - links VTK libraries
[Actual Problem ; ] Again only occurs in Windows , works fine in Linux.
Everything compiles fine and I have only problem wihen executing the PluginB , which uses VTK libraries.
During executing PluginB , it creates a QWidget which set as central widget in a QMainWindow.(there can be many QMainWindow's at once) Inside this QWidget I create a QVTWidget and create a dummy sphere as follows,
QVTKWidget qtWidget = new QVTKWidget(this); qtWidget->resize(512, 512);
vtkSmartPointer sphereSource = vtkSmartPointer::New(); sphereSource->Update(); vtkSmartPointer sphereMapper = vtkSmartPointer::New(); sphereMapper->SetInputConnection(sphereSource->GetOutputPort()); vtkSmartPointer sphereActor = vtkSmartPointer::New(); sphereActor->SetMapper(sphereMapper);
// VTK Renderer vtkSmartPointer leftRenderer =vtkSmartPointer::New(); leftRenderer->AddActor(sphereActor);
qtWidget->GetRenderWindow()->AddRenderer(leftRenderer); QVBoxLayout *vboxLayout = new QVBoxLayout; vboxLayout->addWidget(qtWidget); setLayout(vboxLayout);
During execution QT warns about multiple threads ,but I never create any new threads nor VTK (AFAIK).
QObject: Cannot create children for a parent that is in a different thread.(Parent is QObject(0xdbe0d70), parent's thread is QThread(0x3370f8), current thread is QThread(0xdc427f8)
(But when I comment out the line vboxLayout->addWidget(qtWidget); this disappears. )
And when I perforce any operation on QVTKWidget ,application开发者_C百科 crash .Error log is
> Program received signal SIGSEGV,
> Segmentation fault. 0x01024c41 in
> QRegion::isEmpty (this=0x28d480) at
> painting\qregion.cpp:3975 3975
> painting\qregion.cpp: No such file or
> directory.
> in painting\qregion.cpp (gdb) back
> #0 0x01024c41 in QRegion::isEmpty (this=0x28d480)
> at painting\qregion.cpp:3975
> #1 0x00f0f18a in QWidgetPrivate::childAt_helper
> (this=0xf3957a0, p=...,
> ignoreChildrenInDestructor=false) at kernel\qwidget.cpp:9641
> #2 0x00f0f109 in QWidgetPrivate::childAt_helper
> (this=0xb3c8218, p=...,
> ignoreChildrenInDestructor=false) at kernel\qwidget.cpp:9636
> #3 0x00f0ef9e in QWidget::childAt (this=0x3be0b0, p=...)
> at kernel\qwidget.cpp:9600
> #4 0x00f27bb6 in QETWidget::translateMouseEvent
> (this=0xf3701e8, msg=...)
> at kernel\qapplication_win.cpp:3114
> #5 0x00f234db in QtWndProc@16 (hwnd=0x70af4, message=513, wParam=1,
> lParam=14090539) at kernel\qapplication_win.cpp:1629
> #6 0x767a6238 in USER32!IsDialogMessageW () from
> C:\Windows\syswow64\user32.dll
> #7 0x00070af4 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.)
Any tips ? Why it compains about multiple thread at the first time?
Finally I found the solution.. I had compiled VTK libraries for Release version.But all other components I build Debug version. Since there are two QT libraries are linked(Release and Debug version), QT create two threads for each version. Finally I build all with Release build option and everything works fine.
精彩评论