mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Fix init order of generated C++ code
Like in commit 625eb733d3
for the
interpreter, call `set_component` on the Window before running the setup
code that might set the focus_item.
This commit is contained in:
parent
625eb733d3
commit
bd79bb6ac8
1 changed files with 2 additions and 5 deletions
|
@ -931,10 +931,7 @@ fn generate_component(
|
|||
Declaration::Function(Function {
|
||||
name: "show".into(),
|
||||
signature: "() const".into(),
|
||||
statements: Some(vec![
|
||||
"window.set_component(**self_weak.lock());".into(),
|
||||
"window.show();".into(),
|
||||
]),
|
||||
statements: Some(vec!["window.show();".into()]),
|
||||
..Default::default()
|
||||
}),
|
||||
));
|
||||
|
@ -955,7 +952,6 @@ fn generate_component(
|
|||
name: "run".into(),
|
||||
signature: "() const".into(),
|
||||
statements: Some(vec![
|
||||
"window.set_component(**self_weak.lock());".into(),
|
||||
"show();".into(),
|
||||
"sixtyfps::run_event_loop();".into(),
|
||||
"hide();".into(),
|
||||
|
@ -976,6 +972,7 @@ fn generate_component(
|
|||
format!("auto self_rc = vtable::VRc<sixtyfps::private_api::ComponentVTable, {0}>::make({1});", component_id, maybe_constructor_param),
|
||||
format!("auto self = const_cast<{0} *>(&*self_rc);", component_id),
|
||||
"self->self_weak = vtable::VWeak(self_rc);".into(),
|
||||
"window.set_component(**self_weak.lock());".into(),
|
||||
];
|
||||
create_code.extend(
|
||||
component.setup_code.borrow().iter().map(|code| compile_expression(code, component)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue