Skip to content

Commit

Permalink
Merge pull request #97 from Carifio24/fix-removing-cb
Browse files Browse the repository at this point in the history
Fix issues with attempts to remove callback when widget is destroyed
  • Loading branch information
Carifio24 authored Dec 19, 2024
2 parents da13bc3 + 77027cd commit 41da172
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions glue_ar/qt/export_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,18 @@ 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

def on_widget_destroyed(widget, cb=remove_label_callback):
cb(widget)

update_label(value)
add_callback(instance, property, update_label)
widget.destroyed.connect(remove_label_callback)
widget.destroyed.connect(on_widget_destroyed)

steps = round((max - min) / step)
widget.setMinimum(0)
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,8 @@ def data_files(root_directory):
"ipyfilechooser",
"ipyvuetify",
"glue-vispy-viewers[jupyter]",
# Temporary - see https://github.com/widgetti/ipyvolume/issues/447
"ipython-genutils",
],
"qr": [
"ngrok",
Expand Down

0 comments on commit 41da172

Please sign in to comment.