Skip to content

Commit

Permalink
fix: fix mysterious segfault (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 authored Aug 31, 2023
1 parent 599dff7 commit f676d7e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/superqt/sliders/_labeled.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ def __init__(self, *args, **kwargs) -> None:
fp = self.style().styleHint(QStyle.StyleHint.SH_Button_FocusPolicy)
self.setFocusPolicy(Qt.FocusPolicy(fp))

self._slider = self._slider_class()
self._label = SliderLabel(self._slider, connect=self._setValue)
self._slider = self._slider_class(parent=self)
self._label = SliderLabel(self._slider, connect=self._setValue, parent=self)
self._edge_label_mode: EdgeLabelMode = EdgeLabelMode.LabelIsValue

self._rename_signals()
Expand All @@ -145,12 +145,15 @@ def __init__(self, *args, **kwargs) -> None:
self._slider.sliderMoved.connect(self.sliderMoved.emit)
self._slider.sliderPressed.connect(self.sliderPressed.emit)
self._slider.sliderReleased.connect(self.sliderReleased.emit)
self._slider.valueChanged.connect(self._label.setValue)
self._slider.valueChanged.connect(self.valueChanged.emit)
self._slider.valueChanged.connect(self._on_slider_value_changed)
self._label.editingFinished.connect(self.editingFinished)

self.setOrientation(orientation)

def _on_slider_value_changed(self, v):
self._label.setValue(v)
self.valueChanged.emit(v)

def _setValue(self, value: float):
"""Convert the value from float to int before setting the slider value."""
self._slider.setValue(int(value))
Expand Down

0 comments on commit f676d7e

Please sign in to comment.