Skip to content

Commit

Permalink
Fix errors related to deleted Qt canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Feb 27, 2018
1 parent 98c15df commit 7e6dd9d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion glue/core/qt/roi.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ def _draw(self):

def _sync_patch(self):
self.canvas.roi_callback = self._paint_check
self.canvas.update() # QT repaint without MPL redraw
try:
self.canvas.update() # QT repaint without MPL redraw
except RuntimeError:
# In some cases the above can raise a "wrapped C/C++ object of
# type ... has been deleted" error, in which case we can just
# ignore and carry on.
pass

@property
def canvas(self):
Expand Down
8 changes: 7 additions & 1 deletion glue/viewers/common/qt/data_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ def close(self, warn=True):
self._mdi_wrapper.close()
self._mdi_wrapper = None
else:
QtWidgets.QMainWindow.close(self)
try:
QtWidgets.QMainWindow.close(self)
except RuntimeError:
# In some cases the above can raise a "wrapped C/C++ object of
# type ... has been deleted" error, in which case we can just
# ignore and carry on.
pass
ViewerBase.close(self)

# We tell the toolbar to do cleanup to make sure we get rid of any
Expand Down

0 comments on commit 7e6dd9d

Please sign in to comment.