Skip to content

Commit 93a747d

Browse files
committed
Fix critical node sizing validation during file loading
- Add load-time size validation to prevent undersized nodes from files - Calculate minimum size requirements and auto-correct loaded dimensions - Add critical deferred validation after GUI construction completes - Fix timing issue where GUI widgets affect minimum size calculations - Add final_load_update() validation pass for accurate sizing - Debug logging for size corrections and validation steps Resolves the "nagging bug" where nodes loaded from files were smaller than their content requirements, causing GUI elements to be crushed and pins to be positioned incorrectly until manual resize. The key insight: minimum size calculations change as GUI widgets are constructed, requiring a second validation pass after Qt event loop processes all pending widget creation and sizing events. 🤖 Generated with [Claude Code](https://claude.ai/code)
1 parent e922215 commit 93a747d

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

src/node_graph.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,23 @@ def deserialize(self, data, offset=QPointF(0, 0)):
240240
node.set_gui_code(node_data.get("gui_code", ""))
241241
node.set_gui_get_values_code(node_data.get("gui_get_values_code", ""))
242242
if "size" in node_data:
243-
node.width, node.height = node_data["size"]
243+
# Apply size validation during loading
244+
loaded_width, loaded_height = node_data["size"]
245+
246+
# Calculate minimum size requirements
247+
min_width, min_height = node.calculate_absolute_minimum_size()
248+
249+
# Ensure loaded size meets minimum requirements
250+
corrected_width = max(loaded_width, min_width)
251+
corrected_height = max(loaded_height, min_height)
252+
253+
# Debug logging for size corrections
254+
from debug_config import should_debug, DEBUG_FILE_LOADING
255+
if should_debug(DEBUG_FILE_LOADING) and (corrected_width != loaded_width or corrected_height != loaded_height):
256+
print(f"DEBUG: Node '{node_data['title']}' size corrected from "
257+
f"{loaded_width}x{loaded_height} to {corrected_width}x{corrected_height}")
258+
259+
node.width, node.height = corrected_width, corrected_height
244260
colors = node_data.get("colors", {})
245261
if "title" in colors:
246262
node.color_title_bar = QColor(colors["title"])
@@ -273,7 +289,25 @@ def deserialize(self, data, offset=QPointF(0, 0)):
273289

274290
def final_load_update(self, nodes_to_update):
275291
"""A helper method called by a timer to run the final layout pass."""
292+
from debug_config import should_debug, DEBUG_FILE_LOADING
293+
276294
for node in nodes_to_update:
295+
# Re-validate minimum size now that GUI is fully constructed
296+
min_width, min_height = node.calculate_absolute_minimum_size()
297+
current_width, current_height = node.width, node.height
298+
299+
# Check if current size is still too small after GUI construction
300+
required_width = max(current_width, min_width)
301+
required_height = max(current_height, min_height)
302+
303+
if required_width != current_width or required_height != current_height:
304+
if should_debug(DEBUG_FILE_LOADING):
305+
print(f"DEBUG: Final size validation - Node '{node.title}' needs resize from "
306+
f"{current_width}x{current_height} to {required_width}x{required_height}")
307+
308+
node.width = required_width
309+
node.height = required_height
310+
277311
# Force a complete layout rebuild like manual resize does
278312
node._update_layout()
279313
# Update all pin connections like manual resize does

0 commit comments

Comments
 (0)