[vtk-developers] Fwd: QVTKWidget segfault on Linux with Qt5, VTK6.2, GCC4.9, C++14

Marcus D. Hanwell marcus.hanwell at kitware.com
Mon Jan 12 15:46:03 EST 2015


On Mon, Jan 12, 2015 at 11:30 AM, Júlio Hoffimann
<julio.hoffimann at gmail.com> wrote:
> Thank you Marcus, please reply as soon as you have a working commit. Also
> let me know if you need anything.
>
It is a simple issue with memory management, I just needed to sit down
with GDB for a little longer. You do not assign ownership of your
widget to anything, but you do place it in a smart pointer which
decrements the reference count when it goes out of scope. Enabling it
causes the widget to be registered, and hence called in later renders.

Simply adding 'orientationMarker->Register(NULL);' to your VTKViewer
constructor will fix the crash (but introduce a memory leak). Simply
adding a vtkNew<vtkOrientationMarkerWidget> m_widget to the class
member would automatically instantiate the object, and delete it once
the class' destructor is called.

I have a few applications using Qt 5 with VTK, and I think most stuff
seems to be working pretty well at this point. Unless you build VTK
with C++14 flags there are posibly issues due to changes in the
language.

Thanks,

Marcus


More information about the vtk-developers mailing list