-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix compiler panic when using
%
size in a flickable
The viewport of a flickable is of ElementType::Native, and `lookup_property` don't query the builtin reserved properties in that case. This commit fix the assert by allowing Type::Invalid as well. Fixes #4163
- Loading branch information
Showing
2 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
tests/cases/issues/issue_4163_flickable_parent_percent.slint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { ListView } from "std-widgets.slint"; | ||
component ShowResult inherits Rectangle { | ||
width: 50%; | ||
height: 100%; | ||
|
||
VerticalLayout { | ||
ListView { | ||
for file[idx] in [1,2,3]:Rectangle { | ||
height: 20px; | ||
// width: parent.width; // change to this line compiles fine | ||
width: 100%; // An error occurred!!! | ||
} | ||
} | ||
} | ||
} | ||
export component TestCase inherits Window { | ||
width: 326px; | ||
height: 326px; | ||
|
||
HorizontalLayout { | ||
width: 100%; | ||
height: 100%; | ||
|
||
ShowResult {} | ||
} | ||
|
||
|
||
fli := Flickable { | ||
viewport-height: 1000px; | ||
viewport-width: 2000px; | ||
rec := Rectangle { | ||
width: 100%; | ||
height: parent.height; | ||
} | ||
} | ||
|
||
out property <bool> test: | ||
// The % applies to the viewport | ||
rec.width == 2000px && | ||
// While the parent applies to the flickable | ||
rec.height == 326px; | ||
} | ||
|
||
/* | ||
```cpp | ||
auto handle = TestCase::create(); | ||
const TestCase &instance = *handle; | ||
assert(instance.get_test()); | ||
``` | ||
```rust | ||
let instance = TestCase::new().unwrap(); | ||
assert!(instance.get_test()); | ||
``` | ||
*/ |