Skip to content

Commit

Permalink
Detect binding loops when it involve the condition of a if in a layout
Browse files Browse the repository at this point in the history
Fixes #7126
  • Loading branch information
ogoffart committed Dec 17, 2024
1 parent 21649f2 commit b805438
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/compiler/passes/binding_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ fn visit_layout_items_dependencies<'a>(
) {
for it in items {
let mut element = it.element.clone();
if element.borrow().repeated.is_some() {
if element.borrow().repeated.as_ref().map(|r| recurse_expression(&r.model, vis)).is_some() {
element = it.element.borrow().base_type.as_component().root_element.clone();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright © SixtyFPS GmbH <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0

component Wrapper {
width: 100%;
height: 100%;

Rectangle {
// ^error{The binding for the property 'layoutinfo-h' is part of a binding loop}
VerticalLayout {
// ^error{The binding for the property 'layoutinfo-h' is part of a binding loop}
if root.width > 200px: Rectangle { }
}
}
}

component WrapperInherited inherits Rectangle {
// ^error{The binding for the property 'layoutinfo-h' is part of a binding loop}
VerticalLayout {
// ^error{The binding for the property 'layoutinfo-h' is part of a binding loop}
if root.width > 200px: Rectangle { }
}
}

export component Test inherits Window {

VerticalLayout {
HorizontalLayout {
// ^error{The binding for the property 'width' is part of a binding loop}
// ^^error{The binding for the property 'width' is part of a binding loop}
// ^^^error{The binding for the property 'layout-cache' is part of a binding loop}
WrapperInherited { }
Wrapper { }
// ^error{The binding for the property 'layoutinfo-h' is part of a binding loop}
}
}
}

0 comments on commit b805438

Please sign in to comment.