Skip to content

Commit 34557ad

Browse files
committed
fix: block spin boxes to prevent defaults triggering update
1 parent 410bd6c commit 34557ad

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

loopstructural/gui/modelling/model_definition/bounding_box.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,36 @@ def set_bounding_box(self, bounding_box):
3232
bounding_box : object
3333
BoundingBox-like object with `origin` and `maximum` sequences of length 3.
3434
"""
35-
self.originXSpinBox.setValue(bounding_box.origin[0])
36-
self.maxXSpinBox.setValue(bounding_box.maximum[0])
37-
self.originYSpinBox.setValue(bounding_box.origin[1])
38-
self.maxYSpinBox.setValue(bounding_box.maximum[1])
39-
self.originZSpinBox.setValue(bounding_box.origin[2])
40-
self.maxZSpinBox.setValue(bounding_box.maximum[2])
35+
# Block spinbox signals to avoid emitting valueChanged while setting values
36+
spinboxes = (
37+
self.originXSpinBox,
38+
self.maxXSpinBox,
39+
self.originYSpinBox,
40+
self.maxYSpinBox,
41+
self.originZSpinBox,
42+
self.maxZSpinBox,
43+
)
44+
for sb in spinboxes:
45+
try:
46+
sb.blockSignals(True)
47+
except Exception:
48+
pass
49+
50+
try:
51+
self.originXSpinBox.setValue(bounding_box.origin[0])
52+
self.maxXSpinBox.setValue(bounding_box.maximum[0])
53+
self.originYSpinBox.setValue(bounding_box.origin[1])
54+
self.maxYSpinBox.setValue(bounding_box.maximum[1])
55+
self.originZSpinBox.setValue(bounding_box.origin[2])
56+
self.maxZSpinBox.setValue(bounding_box.maximum[2])
57+
finally:
58+
# Ensure signals are unblocked even if setting values raises
59+
for sb in spinboxes:
60+
try:
61+
sb.blockSignals(False)
62+
except Exception:
63+
pass
64+
4165
self._update_bounding_box_styles()
4266

4367
def useCurrentViewExtent(self):

loopstructural/main/data_manager.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ def get_bounding_box(self):
169169
"""Get the current bounding box."""
170170
return self._bounding_box
171171

172-
173172
def set_elevation(self, elevation):
174173
"""Set the elevation for the model."""
175174
self.elevation = elevation

0 commit comments

Comments
 (0)