Commit a06d2338 authored by Jaswant Panchumarti's avatar Jaswant Panchumarti Committed by jaswantp
Browse files

Fix Memory Leak In QVTKRenderWindowInteractor

- This fixes memory leaks on unix systems with VirtualGL.
- With VirtualGL (vglrun) hidden widgets/windows are not
correctly handled. So with the previous implementation,
`Finalize` is never called and there are several leaks reported
upon exiting the python interpreter.
- Instead, connect the parent's destroyed signal to
widget's close slot. Qt does not close child when parent
is closed.
- closeEvent is already implemented to call Finalize.
parent 7c3c9256
......@@ -322,12 +322,11 @@ class QVTKRenderWindowInteractor(QVTKRWIBaseClass):
self._Iren.GetRenderWindow().AddObserver('CursorChangedEvent',
self.CursorChangedEvent)
#Create a hidden child widget and connect its destroyed signal to its
#parent ``Finalize`` slot. The hidden children will be destroyed before
#its parent thus allowing cleanup of VTK elements.
self._hidden = QWidget(self)
self._hidden.hide()
self._hidden.destroyed.connect(self.Finalize)
# If we've a parent, it does not close the child when closed.
# Connect the parent's destroyed signal to this widget's close
# slot for proper cleanup of VTK objects.
if self.parent():
self.parent().destroyed.connect(self.close)
def __getattr__(self, attr):
"""Makes the object behave like a vtkGenericRenderWindowInteractor"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment