Skip to content

Commit 8baee69

Browse files
dfaure-kdabogoffart
authored andcommitted
compiler: add missing bindings from organized-data to row/col/rowspan/colspan
With testcase from Olivier for a binding loop col -> x -> col
1 parent 01a4193 commit 8baee69

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

internal/compiler/layout.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,8 @@ pub struct GridLayout {
471471
}
472472

473473
impl GridLayout {
474-
pub fn visit_named_references(&mut self, visitor: &mut impl FnMut(&mut NamedReference)) {
474+
pub fn visit_rowcol_named_references(&mut self, visitor: &mut impl FnMut(&mut NamedReference)) {
475475
for cell in &mut self.elems {
476-
cell.item.constraints.visit_named_references(visitor);
477476
if let RowColExpr::Named(ref mut e) = cell.col_expr {
478477
visitor(e);
479478
}
@@ -487,6 +486,13 @@ impl GridLayout {
487486
visitor(e);
488487
}
489488
}
489+
}
490+
491+
pub fn visit_named_references(&mut self, visitor: &mut impl FnMut(&mut NamedReference)) {
492+
self.visit_rowcol_named_references(visitor);
493+
for cell in &mut self.elems {
494+
cell.item.constraints.visit_named_references(visitor);
495+
}
490496
self.geometry.visit_named_references(visitor);
491497
}
492498
}

internal/compiler/passes/binding_analysis.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,10 @@ fn recurse_expression(
516516
g.visit_named_references(&mut |nr| vis(&nr.clone().into(), P))
517517
}
518518
Expression::OrganizeGridLayout(layout) => {
519-
let mut g = layout.geometry.clone();
520-
g.rect = Default::default();
521-
g.visit_named_references(&mut |nr| vis(&nr.clone().into(), P))
519+
let mut layout = layout.clone();
520+
layout.visit_rowcol_named_references(&mut |nr: &mut NamedReference| {
521+
vis(&nr.clone().into(), P)
522+
});
522523
}
523524
Expression::SolveGridLayout { layout_organized_data_prop, layout, orientation }
524525
| Expression::ComputeGridLayoutInfo { layout_organized_data_prop, layout, orientation } => {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright © Klarälvdalens Datakonsult AB, a KDAB Group company, [email protected]
2+
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3+
4+
export component TestCase inherits Window {
5+
// ^warning{The binding for the property 'layoutinfo-h' is part of a binding loop (lay1.width -> lay1.layout-cache-h -> x -> col -> lay1.layout-organized-data -> lay1.layoutinfo-h -> root.layoutinfo-h).↵This was allowed in previous version of Slint, but is deprecated and may cause panic at runtime}
6+
7+
lay1 := GridLayout {
8+
// ^warning{The binding for the property 'width' is part of a binding loop (lay1.width -> lay1.layout-cache-h -> x -> col -> lay1.layout-organized-data -> lay1.layoutinfo-h -> root.layoutinfo-h).↵This was allowed in previous version of Slint, but is deprecated and may cause panic at runtime}
9+
// ^^warning{The binding for the property 'layout-cache-h' is part of a binding loop (lay1.width -> lay1.layout-cache-h -> x -> col -> lay1.layout-organized-data -> lay1.layoutinfo-h -> root.layoutinfo-h).↵This was allowed in previous version of Slint, but is deprecated and may cause panic at runtime}
10+
// ^^^warning{The binding for the property 'x' is part of a binding loop (lay1.width -> lay1.layout-cache-h -> x -> col -> lay1.layout-organized-data -> lay1.layoutinfo-h -> root.layoutinfo-h).↵This was allowed in previous version of Slint, but is deprecated and may cause panic at runtime}
11+
// ^^^^warning{The binding for the property 'layoutinfo-h' is part of a binding loop (lay1.width -> lay1.layout-cache-h -> x -> col -> lay1.layout-organized-data -> lay1.layoutinfo-h -> root.layoutinfo-h).↵This was allowed in previous version of Slint, but is deprecated and may cause panic at runtime}
12+
// ^^^^^warning{The binding for the property 'layout-organized-data' is part of a binding loop (lay1.width -> lay1.layout-cache-h -> x -> col -> lay1.layout-organized-data -> lay1.layoutinfo-h -> root.layoutinfo-h).↵This was allowed in previous version of Slint, but is deprecated and may cause panic at runtime}
13+
Text {
14+
row: 1;
15+
col: self.x > 10px ? 3 : 4;
16+
// ^warning{The binding for the property 'col' is part of a binding loop (lay1.width -> lay1.layout-cache-h -> x -> col -> lay1.layout-organized-data -> lay1.layoutinfo-h -> root.layoutinfo-h).↵This was allowed in previous version of Slint, but is deprecated and may cause panic at runtime}
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)