mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Don't optimize const state property
state info properties are special and cannot simply be inlined or set (because we need to record the time it was changed and stuff) So disable the optimization for now. In fact, what could be done is to remove the state entirely if the state property is constant. But that change is a bit more involved This patch does: - Don't inline const state property - Don't generate a call to .set in the generated code - Also allowed to debug the expression with a context from the generator (added T generic parameter to the pretty printer) Fix panic reported in https://github.com/slint-ui/slint/issues/1327#issuecomment-1151244049
This commit is contained in:
parent
a2484cfc64
commit
9111dbfbce
6 changed files with 84 additions and 8 deletions
|
@ -426,7 +426,7 @@ fn handle_property_init(
|
|||
let init_expr =
|
||||
compile_expression_wrap_return(&binding_expression.expression.borrow(), ctx);
|
||||
|
||||
init.push(if binding_expression.is_constant {
|
||||
init.push(if binding_expression.is_constant && !binding_expression.is_state_info {
|
||||
format!("{}.set({});", prop_access, init_expr)
|
||||
} else {
|
||||
let binding_code = format!(
|
||||
|
|
|
@ -419,7 +419,7 @@ fn handle_property_init(
|
|||
} else {
|
||||
let tokens_for_expression =
|
||||
compile_expression(&binding_expression.expression.borrow(), ctx);
|
||||
init.push(if binding_expression.is_constant {
|
||||
init.push(if binding_expression.is_constant && !binding_expression.is_state_info {
|
||||
let t = rust_type(prop_type).unwrap_or(quote!(_));
|
||||
|
||||
// When there is a `return` statement, we must use a lambda expression in the generated code so that the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue