大家好,QT Plugin,VTK QT Widget,多线程和链接问题?
这将是一个长期的问题,跳过[背景]如果它不是neccasary;)
背景]
我开发了模块化基于Qt的application.Application通过基于QT的插件是可扩展的。 如该图所示,主要有3份(以红色的数字)
1)libAppCore - 应用程序的核心,其限定pluginterfaces,主UIS,interations..etc
2)App.exe - 实现一些内置插件和主应用程序执行的应用程序。
3)基于Qt的插件 - 几个插件,它实现在libAppCore.dll
插件接口,这里的每个组件是如何联系对方:
libAppCore链接Qt库。
APP.EXE链接libAppCore.DLL和Qt库(APP.EXE使用一些其它的Qt类不使用我的libAppCore.DLL)
插件(libAppQTPluginA.DLL,libAppQTPluginB.DLL) - 链接libAppCore。 DLL和QT库。 libAppQTPluginA.DLL - 链接的OpenGL libAppQTPluginB.DLL - 链接库VTK
[实际的问题; ]再次只发生在Windows中,在Linux中正常工作。
一切都编译好,我只有执行pluginB,它使用VTK库的问题。
在执行PluginB的过程中,它会创建一个QWidget,它被设置为QMainWindow中的中心控件。(可以有很多的QMainWindow的一次) 这里面的QWidget我创建了一个QVTWidget并创建一个虚拟球体如下,
QVTKWidget qtWidget =新QVTKWidget(本); 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); ();}};}}}}}}} QVBoxLayout * vboxLayout = new QVBoxLayout; vboxLayout-> addWidget(qtWidget); setLayout(vboxLayout);
执行期间QT会警告多个线程,但我从不创建任何新线程或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)
(但是,当我注释掉线vboxLayout-> addWidget(qtWidget);这将消失。)
当我Perforce公司在QVTKWidget任何操作,应用程序崩溃.Error日志
> 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 [email protected] (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.)
任何提示?为什么它第一次对多线程有所了解?