Skip to content

Fix recursion when component with height-for-width items is in a FlexboxLayout#11382

Open
dfaure-kdab wants to merge 2 commits intoslint-ui:masterfrom
dfaure-kdab:wip/dfaure/flex-fix-h-for-w-recursion
Open

Fix recursion when component with height-for-width items is in a FlexboxLayout#11382
dfaure-kdab wants to merge 2 commits intoslint-ui:masterfrom
dfaure-kdab:wip/dfaure/flex-fix-h-for-w-recursion

Conversation

@dfaure-kdab
Copy link
Copy Markdown
Collaborator

Revert "FlexboxLayout: detect binding loops when components have height-for-width children (#11381)"

This reverts commit edf9800.


Fix recursion when component with height-for-width items is in a FlexboxLayout

When a component containing Text with word-wrap or Image with aspect
ratio is placed inside a FlexboxLayout, evaluating the component's
vertical layout info would panic with recursion: layoutinfo-v →
internal layout → Text/Image reads width → component width → layout
cache → layoutinfo-v.

For builtins directly in a layout, the VTable cross_axis_constraint
parameter breaks this cycle. But for components, layoutinfo-v is a
property binding with no parameter mechanism.

Fix: add a cross-axis constraint thread-local in i_slint_core::layout.
Text and Image items check it when their explicit constraint is -1
(meaning "no constraint passed"). The thread-local is set at two
levels:

  • Compiled path: SolveFlexboxLayout wraps its entire expression
    (including cells computation) with set_cross_axis_constraint
    (container_width), so all nested ImplicitLayoutInfo(Vertical, -1)
    calls inside components see the constraint.

  • Interpreter path: get_layout_info_with_constraint saves/restores the
    thread-local at each component boundary, so nested components get
    the correct constraint for their level.

…boxLayout

When a component containing Text with word-wrap or Image with aspect
ratio is placed inside a FlexboxLayout, evaluating the component's
vertical layout info would panic with recursion: layoutinfo-v →
internal layout → Text/Image reads width → component width → layout
cache → layoutinfo-v.

For builtins directly in a layout, the VTable cross_axis_constraint
parameter breaks this cycle. But for components, layoutinfo-v is a
property binding with no parameter mechanism.

Fix: add a cross-axis constraint thread-local in i_slint_core::layout.
Text and Image items check it when their explicit constraint is -1
(meaning "no constraint passed"). The thread-local is set at two
levels:

- Compiled path: SolveFlexboxLayout wraps its entire expression
  (including cells computation) with set_cross_axis_constraint
  (container_width), so all nested ImplicitLayoutInfo(Vertical, -1)
  calls inside components see the constraint.

- Interpreter path: get_layout_info_with_constraint saves/restores the
  thread-local at each component boundary, so nested components get
  the correct constraint for their level.
@dfaure-kdab dfaure-kdab force-pushed the wip/dfaure/flex-fix-h-for-w-recursion branch from f2beb23 to 2aa4783 Compare April 14, 2026 17:36
@dfaure-kdab dfaure-kdab enabled auto-merge (rebase) April 14, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant