Skip to content

Commit 8a63a10

Browse files
committed
ColorMapManager: attempt to fix segfault with PySide6 on Linux
1 parent bf12348 commit 8a63a10

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

plotpy/widgets/colormap/manager.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,16 @@ def __init__(
182182
select_gbox.setLayout(select_gbox_layout)
183183

184184
# Edit the selected colormap
185-
self.colormap_editor = ColorMapEditor(
186-
self, colormap=deepcopy(self._cmap_choice.currentData())
187-
)
185+
current_cmap = self._cmap_choice.currentData()
186+
# This test is necessary because the currentData method returns a QVariant
187+
# object, which may be handled differently by PyQt5, PySide2 and PySide6.
188+
# This is an attempt to fix an issue with PySide6 (segfault).
189+
if isinstance(current_cmap, EditableColormap):
190+
current_cmap = deepcopy(current_cmap)
191+
else:
192+
current_cmap = None
193+
self.colormap_editor = ColorMapEditor(self, colormap=current_cmap)
194+
188195
self._edit_gbox = QW.QGroupBox(_("Edit the selected colormap"))
189196
edit_gbox_layout = QW.QVBoxLayout()
190197
edit_gbox_layout.setContentsMargins(0, 0, 0, 0)

0 commit comments

Comments
 (0)