Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ requirements:
- python
- fabio
- hexrd=={{ hexrd_version }}
# We have some issue removing artists in matplotlib 3.10
# Fix the matplotlib version until that is resolved.
- matplotlib-base<3.10
- matplotlib-base
- Pillow
- pyhdf
# This next one is needed to fix the app name on Mac
Expand Down
18 changes: 15 additions & 3 deletions hexrdgui/image_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from PySide6.QtCore import QThreadPool, QTimer, Signal, Qt
from PySide6.QtWidgets import QFileDialog, QMessageBox, QProgressDialog

from matplotlib.artist import Artist
from matplotlib.axes import Axes
from matplotlib.backends.backend_qtagg import FigureCanvas
from matplotlib.figure import Figure
Expand Down Expand Up @@ -187,10 +188,10 @@ def clear(self):
self.clear_figure()

def clear_figure(self):
self.remove_all_overlay_artists()
self.figure.clear()
self.raw_axes.clear()
self.axes_images.clear()
self.remove_all_overlay_artists()
self.clear_azimuthal_integral_axis()
self.mode = None

Expand Down Expand Up @@ -768,7 +769,7 @@ def update_overlays(self):

def clear_detector_borders(self):
while self.cached_detector_borders:
self.cached_detector_borders.pop(0).remove()
_safe_remove_artist(self.cached_detector_borders.pop(0))

self.draw_idle()

Expand All @@ -792,7 +793,7 @@ def draw_detector_borders(self):

def clear_stereo_border_artists(self):
while self.stereo_border_artists:
self.stereo_border_artists.pop(0).remove()
_safe_remove_artist(self.stereo_border_artists.pop(0))

self.draw_idle()

Expand Down Expand Up @@ -2222,3 +2223,14 @@ def to_stereo(xys, panel, iviewer):
raise Exception(f'Unknown mode: {mode}')

return funcs[mode]


def _safe_remove_artist(artist: Artist):
# Starting in matplotlib 3.10, we cannot remove artists from a figure
# that has already been cleared. I don't know of any easy way to check
# if the axis has been cleared, though, so for now, we just try to
# remove the artist and ignore the relevant exception if it occurs.
try:
artist.remove()
except NotImplementedError:
pass
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
install_reqs = [
'hexrd',
'fabio>=0.11',
# We have some issue removing artists in matplotlib 3.10
# Fix the matplotlib version until that is resolved.
'matplotlib<3.10',
'matplotlib',
'Pillow',
# PySide 6.8.0 is causing segmentation faults in the testing
# Keep this version downgraded until that is fixed.
Expand Down
Loading