mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-27 20:42:25 +00:00
Compiler: Don't panic when a Row is repeated in a GridLayout
Fixes #3729
This commit is contained in:
parent
49571c8bf2
commit
ae4debafe2
2 changed files with 28 additions and 1 deletions
|
@ -98,7 +98,20 @@ fn lower_element_layout(
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
match base_type.name.as_str() {
|
match base_type.name.as_str() {
|
||||||
"Row" => panic!("Error caught at element lookup time"),
|
"Row" => {
|
||||||
|
// We shouldn't lower layout if we have a Row in there. Unless the Row is the root of a repeated item,
|
||||||
|
// in which case another error has been reported
|
||||||
|
assert!(
|
||||||
|
diag.has_error()
|
||||||
|
&& Rc::ptr_eq(&component.root_element, elem)
|
||||||
|
&& component
|
||||||
|
.parent_element
|
||||||
|
.upgrade()
|
||||||
|
.map_or(false, |e| e.borrow().repeated.is_some()),
|
||||||
|
"Error should have been caught at element lookup time"
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
"GridLayout" => lower_grid_layout(component, elem, diag),
|
"GridLayout" => lower_grid_layout(component, elem, diag),
|
||||||
"HorizontalLayout" => lower_box_layout(elem, diag, Orientation::Horizontal),
|
"HorizontalLayout" => lower_box_layout(elem, diag, Orientation::Horizontal),
|
||||||
"VerticalLayout" => lower_box_layout(elem, diag, Orientation::Vertical),
|
"VerticalLayout" => lower_box_layout(elem, diag, Orientation::Vertical),
|
||||||
|
|
14
internal/compiler/tests/syntax/layout/if_in_grid_row.slint
Normal file
14
internal/compiler/tests/syntax/layout/if_in_grid_row.slint
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
|
||||||
|
|
||||||
|
export component Test {
|
||||||
|
property <bool> condition;
|
||||||
|
|
||||||
|
GridLayout {
|
||||||
|
// Issue #3729
|
||||||
|
if (condition) : r := Row {
|
||||||
|
// ^error{'if' or 'for' expressions are not currently supported in grid layouts}
|
||||||
|
Rectangle {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue