You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello:= Rectangle{background: xxx.color;
xxx := Text{}}
export AppWindow:= Window{Hello{
states [
highlight when width < height:{
background: red;}]}}
This will get lowered to something like
export AppWindow:= Window{Hello{
property <int> state: ...;
background: state == 1 ? red : xxx.color;}}
But xxx.color can't be represented properly because xxx is inaccessible from within the AppWindow context.
This may resulting in panics in the compiler in further passes.
To fix this, we need to change the representation of properties access to be able to access properties within element of components.
Original bug report
Observed with slint 0.2.5 from crates.io and with a head version from git, commit 5bc56a3.
Steps to reproduce:
Start with cargo generate --git https://github.com/slint-ui/slint-rust-template.
error: failed to run custom build command for `slint-bug-state-background v0.1.0 (D:\0\slint-bug-state-background)`
Caused by:
process didn't exit successfully: `D:\0\slint-bug-state-background\target\debug\build\slint-bug-state-background-81a7ccd94231b199\build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\i-slint-compiler-0.2.5\llr\lower_expression.rs:35:34
It works just fine when I load the .slint file at runtime using slint_interpreter.
The problem is specifically with the background: if I comment out the line background: red; but leave the rest of the added states in place, the error disappears.
No error if I change some of the other properties instead of background (I tried text and opacity).
Assigning to background in the clicked callback instead of states works fine.
Changing a custom property instead of background also works and gives a workaround.
Workaround:
Create a custom property and bind background to it:
Some binding can't be express with the current data structures because
they reference propertis within inner elements within a component.
The fix is a bit involved and the best is to have an error istead of a
panic, for now.
Some binding can't be express with the current data structures because
they reference propertis within inner elements within a component.
The fix is a bit involved and the best is to have an error istead of a
panic, for now.
ogoffart
changed the title
Compiler panics on changing Button background in states
Compiler unable to represent state property binding when the default binding is declared in a different component
Aug 16, 2022
Thanks for the well written bug report.
I was able to reproduce and found out what the problem is.
This is a difficult problem to solve so I took the liberty to edit the description and title. I'm going to keep the issue open and implemented a workaround by making this code an error for now: #1490
The actual fix will need some more refactorings in the compiler which will be done in a later release.
Some binding can't be express with the current data structures because
they reference propertis within inner elements within a component.
The fix is a bit involved and the best is to have an error istead of a
panic, for now.
Consider
This will get lowered to something like
But
xxx.color
can't be represented properly becausexxx
is inaccessible from within the AppWindow context.This may resulting in panics in the compiler in further passes.
To fix this, we need to change the representation of properties access to be able to access properties within element of components.
Original bug report
Observed with slint 0.2.5 from crates.io and with a head version from git, commit 5bc56a3.
Steps to reproduce:
cargo generate --git https://github.com/slint-ui/slint-rust-template
.modified appwindow.slint
cargo build
Error:
Error output with RUST_BACKTRACE=1
Additional observations:
slint_interpreter
.background: red;
but leave the rest of the addedstates
in place, the error disappears.background
(I triedtext
andopacity
).background
in theclicked
callback instead ofstates
works fine.background
also works and gives a workaround.Workaround:
Create a custom property and bind
background
to it:OS: Windows
Slint style: fluent
(EDITED: added a workaround. Seems obvious but somehow didn't occur to me when I wrote the original description).
The text was updated successfully, but these errors were encountered: