Skip to content

Commit

Permalink
Fix issues with attempts to remove callback when widget is destroyed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Dec 19, 2024
1 parent a94a593 commit 5bd85d5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions glue_ar/qt/export_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ def _widgets_for_property(self,
def update_label(value):
value_label.setText(f"{value:.{places}f}")

def remove_label_callback(*args):
remove_callback(instance, property, update_label)
def remove_label_callback(widget, update_label=update_label):
try:
remove_callback(instance, property, update_label)
except ValueError:
pass

Check warning on line 76 in glue_ar/qt/export_dialog.py

View check run for this annotation

Codecov / codecov/patch

glue_ar/qt/export_dialog.py#L73-L76

Added lines #L73 - L76 were not covered by tests

update_label(value)
add_callback(instance, property, update_label)
widget.destroyed.connect(remove_label_callback)
widget.destroyed.connect(lambda *args, cb=remove_label_callback: cb(widget))

steps = round((max - min) / step)
widget.setMinimum(0)
Expand Down

0 comments on commit 5bd85d5

Please sign in to comment.