Skip to content

Commit 5b2f800

Browse files
committed
Refactor H5Browser to prevent signal triggering during file selection update
1 parent 4b2b158 commit 5b2f800

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

datalab/widgets/h5browser.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from datalab.adapters_plotpy import CURVESTYLES, create_adapter_from_object
3636
from datalab.config import Conf, _
3737
from datalab.h5 import H5Importer
38-
from datalab.utils.qthelpers import qt_handle_error_message
38+
from datalab.utils.qthelpers import block_signals, qt_handle_error_message
3939

4040
if TYPE_CHECKING:
4141
from plotpy.plot import BasePlot
@@ -851,7 +851,13 @@ def __item_selected_on_tree(self, item: QW.QTreeWidgetItem) -> None:
851851
self.plotpreview.update_plot_preview(node)
852852
self.groupandattrs.update_from_node(node)
853853
# Update the file selector combo box
854-
self.selector.set_current_fname(node.h5file.filename)
854+
with block_signals(self.selector.combo):
855+
# Avoid triggering current file changed signal, which would result in
856+
# loosing the current selection on the tree (side effect: "Show array"
857+
# button would still be enabled if the previous node was an array, except
858+
# that now the current node is not an array, thus causing an error if
859+
# the user clicks on the button).
860+
self.selector.set_current_fname(node.h5file.filename)
855861

856862
def __selector_current_file_changed(self, fname: str) -> None:
857863
"""Selector current file changed

0 commit comments

Comments
 (0)