Skip to content

Commit

Permalink
FIX: Dont allow paint events after destruction
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Feb 6, 2020
1 parent 749199d commit c2a8a23
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tvtk/pyface/ui/qt4/QVTKRenderWindowInteractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def __init__(self, parent=None, **kw):
# before its parent thus allowing cleanup of VTK elements.
self._hidden = QWidget(self)
self._hidden.hide()
self._hidden.destroyed.connect(self.Finalize)
self._hidden.destroyed.connect(self._destroyed)

def __getattr__(self, attr):
"""Makes the object behave like a vtkGenericRenderWindowInteractor"""
Expand Down Expand Up @@ -324,6 +324,14 @@ def _get_win_id(self):
WId = pythonapi.PyCapsule_GetPointer(WId, name)
return str(int(WId))

def _no_paint(self, ev):
pass

def _destroyed(self):
# ensure no paint events get called again
self.paintEvent = self._no_paint
self.Finalize()

def Finalize(self):
'''
Call internal cleanup method on VTK objects
Expand Down

0 comments on commit c2a8a23

Please sign in to comment.