slint/internal/compiler/passes
Simon Hausmann fef9c446a4
Fix missing invocation of init callbacks due to inlining (#4322)
When a component declares an init callback as well as the element that
instantiates it, the init callback of the container would not
get invoked if the container was inlined:

```
component InlinedContainer {
    init => { ... } // not invoked
    @children // force inlining
}

component UseSite {
    InlinedContainer {
        init => { ... }
    }
}
```

That's because the inlining happens very early, before the init
callbacks are collected into the init code. And during inlining that
would be treated like a property binding and the "binding" at the
element site overrides the one at the component site.

One natural approach would be to move the init code collection to an
earlier place before inlining, but that isn't possible because the
boundaries of the compiler components (Rc<Component>) aren't set
up yet (repeated component extraction phase happens much later).

An alternative would be to re-introduce the init callback code in
ElementRc and place it in there at *::from_node() time.

This patch chooses to solve this at the inlining time: When we're in the
first phase of the inlining (the optional one), do what
with the init binding what collect_init_code would do later: Move it
straight into the init_code of the component we're inlining into.

Fixes #4317
2024-01-12 10:14:27 +01:00
..
apply_default_properties_from_style.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
binding_analysis.rs Visit the geometry property as root from binding_analysis 2023-11-24 14:07:42 +01:00
check_expressions.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
check_public_api.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
check_rotation.rs Fix detection of properties when they are only used in two way bindings 2023-12-19 11:14:53 +01:00
clip.rs Fix detection of properties when they are only used in two way bindings 2023-12-19 11:14:53 +01:00
collect_custom_fonts.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
collect_globals.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
collect_init_code.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
collect_structs_and_enums.rs Fix named exports in native code (#3602) 2023-10-05 16:41:10 +02:00
collect_subcomponents.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
compile_paths.rs Warn when using a Path with the software renderer 2023-08-31 12:37:48 +02:00
const_propagation.rs compiler: Store an optional version number with the document 2023-12-18 14:21:50 +01:00
deduplicate_property_read.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
default_geometry.rs Don't steal the x and y properties for dummy parents 2023-10-21 07:30:46 +02:00
embed_glyphs.rs Fix missing font fallback handling on Windows when pre-rendering glyphs for the software renderer (#4245) 2024-01-02 13:37:08 +01:00
embed_images.rs compiler: Implement resource URL remapping 2023-10-12 21:41:26 +02:00
ensure_window.rs Fix compiler panic when there is a component called "Window" 2023-11-20 13:10:31 +01:00
flickable.rs WIP: Add item_geometry to the ComponentVTable 2023-09-13 16:08:37 +02:00
focus_item.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
generate_item_indices.rs Change item indices from usize to u32 2023-09-12 08:53:58 +02:00
infer_aliases_types.rs Fix compiler panic when trying to resolve aliases in invalid import 2023-10-16 16:37:49 +02:00
inlining.rs Fix missing invocation of init callbacks due to inlining (#4322) 2024-01-12 10:14:27 +01:00
lower_absolute_coordinates.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
lower_accessibility.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
lower_component_container.rs Don't steal the x and y properties for dummy parents 2023-10-21 07:30:46 +02:00
lower_layout.rs Fix detection of properties when they are only used in two way bindings 2023-12-19 11:14:53 +01:00
lower_popups.rs Fix compiler panic when there is a component called "Window" 2023-11-20 13:10:31 +01:00
lower_property_to_element.rs Fix detection of properties when they are only used in two way bindings 2023-12-19 11:14:53 +01:00
lower_shadows.rs Fix compiler panic when there is a component called "Window" 2023-11-20 13:10:31 +01:00
lower_states.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
lower_tabwidget.rs Fix generation of geometry prop for some primitives 2023-09-13 16:08:37 +02:00
lower_text_input_interface.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
materialize_fake_properties.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
move_declarations.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
optimize_useless_rectangles.rs Fix optimization pass removing rectangle that have a x and y set 2023-09-13 16:08:37 +02:00
purity_check.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
remove_aliases.rs Fix alias to externaly modified property not being marked as such 2023-08-22 16:20:13 +02:00
remove_return.rs Rust&C++: Fix Return value of complex expression 2023-12-08 17:28:38 +01:00
remove_unused_properties.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
repeater_component.rs compiler: Add layout information the the Element 2023-10-24 15:49:12 +02:00
resolve_native_classes.rs fix resolve_native_classes pass 2023-09-13 16:08:37 +02:00
resolving.rs Fix detection of properties when they are only used in two way bindings 2023-12-19 11:14:53 +01:00
unique_id.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
visible.rs Fix detection of properties when they are only used in two way bindings 2023-12-19 11:14:53 +01:00
z_order.rs Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00