Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with attempts to remove callback when widget is destroyed #97

Merged
merged 3 commits into from
Dec 19, 2024
Merged
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
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 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

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

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

View check run for this annotation

Codecov / codecov/patch

glue_ar/qt/export_dialog.py#L79

Added line #L79 was not covered by tests

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
Loading