mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
Fix compiler panic when optimizing child of layout
Normally, child of layout don't get optimized anyway because the layout sets their `x` and `y` prop, preventing the optimization. But if the rectangle has an opacity, its `x` and `y` property are stolen by the opacity element, and then it can get optimized anyway Fixes #1267
This commit is contained in:
parent
1d18bd634b
commit
b3fe9cc96d
2 changed files with 16 additions and 0 deletions
|
@ -40,6 +40,11 @@ fn can_optimize(elem: &ElementRc) -> bool {
|
|||
return false;
|
||||
};
|
||||
|
||||
if e.child_of_layout {
|
||||
// The `LayoutItem` still has reference to this component, so we cannot remove it
|
||||
return false;
|
||||
}
|
||||
|
||||
let base_type = match &e.base_type {
|
||||
Type::Builtin(base_type) if base_type.name == "Rectangle" => base_type,
|
||||
_ => return false,
|
||||
|
|
11
tests/cases/crashes/issue1267_opacity_in_layout.slint
Normal file
11
tests/cases/crashes/issue1267_opacity_in_layout.slint
Normal file
|
@ -0,0 +1,11 @@
|
|||
// Copyright © SixtyFPS GmbH <info@slint-ui.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
|
||||
|
||||
MainWindow := Window {
|
||||
VerticalLayout {
|
||||
Rectangle {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue