Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when conditional/repeated element ends up traversing the item tree during init() #3214

Open
tronical opened this issue Aug 3, 2023 · 0 comments · May be fixed by #3215
Open

Panic when conditional/repeated element ends up traversing the item tree during init() #3214

tronical opened this issue Aug 3, 2023 · 0 comments · May be fixed by #3215
Labels
a:models&views The implementation of the `for` and ListView (mO,bF) bug Something isn't working

Comments

@tronical
Copy link
Member

tronical commented Aug 3, 2023

The following test-case panics:

export component Test {
    VerticalLayout {
        if true: TextInput {
            init => { self.focus(); }
        }
    }
}

The call to focus() triggers the run-time calling ItemRc::is_visible(), which queries the geometry, which due to default bindings ends up querying the layout, and then we end up recursively in ensure_updated_impl:

rust_panic (@rust_panic:3)
std::panicking::rust_panic_with_hook (@std::panicking::rust_panic_with_hook:186)
std::panicking::begin_panic_handler::{{closure}} (@std::panicking::begin_panic_handler::{{closure}}:57)
std::sys_common::backtrace::__rust_end_short_backtrace (@std::sys_common::backtrace::__rust_end_short_backtrace:6)
rust_begin_unwind (@rust_begin_unwind:30)
core::panicking::panic_fmt (@core::panicking::panic_fmt:15)
core::result::unwrap_failed (@core::result::unwrap_failed:28)
core::result::Result<T,E>::expect (@core::result::Result<T,E>::expect:33)
core::cell::RefCell<T>::borrow_mut (@core::cell::RefCell<T>::borrow_mut:15)
i_slint_core::model::Repeater<C>::ensure_updated_impl (/Users/simon/src/slint/internal/core/model.rs:898)
i_slint_core::model::Repeater<C>::ensure_updated (/Users/simon/src/slint/internal/core/model.rs:887)
slint_interpreter::eval_layout::box_layout_data (/Users/simon/src/slint/internal/interpreter/eval_layout.rs:201)
slint_interpreter::eval_layout::solve_layout (/Users/simon/src/slint/internal/interpreter/eval_layout.rs:114)
slint_interpreter::eval::eval_expression (/Users/simon/src/slint/internal/interpreter/eval.rs:389)
slint_interpreter::dynamic_component::make_binding_eval_closure::{{closure}} (/Users/simon/src/slint/internal/interpreter/dynamic_component.rs:1249)
<alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call (@<alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call:13)
<field_offset::FieldOffset<Item,i_slint_core::properties::Property<T>,field_offset::AllowPin> as i_slint_core::rtti::PropertyInfo<Item,Value>>::set_binding::{{closure}} (/Users/simon/src/slint/internal/core/rtti.rs:143)
<F as i_slint_core::properties::Binding<T>>::evaluate (/Users/simon/src/slint/internal/core/properties.rs:693)
i_slint_core::properties::Property<T>::set_binding::{{closure}} (/Users/simon/src/slint/internal/core/properties.rs:886)
<F as i_slint_core::properties::BindingCallable>::evaluate (/Users/simon/src/slint/internal/core/properties.rs:290)
i_slint_core::properties::alloc_binding_holder::evaluate::{{closure}} (/Users/simon/src/slint/internal/core/properties.rs:393)
i_slint_core::properties::CURRENT_BINDING::<impl i_slint_core::properties::CURRENT_BINDING>::set (/Users/simon/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scoped-tls-hkt-0.1.2/src/lib.rs:264)
i_slint_core::properties::alloc_binding_holder::evaluate (/Users/simon/src/slint/internal/core/properties.rs:392)
i_slint_core::properties::PropertyHandle::update::{{closure}} (/Users/simon/src/slint/internal/core/properties.rs:576)
i_slint_core::properties::PropertyHandle::access (/Users/simon/src/slint/internal/core/properties.rs:481)
i_slint_core::properties::PropertyHandle::update (/Users/simon/src/slint/internal/core/properties.rs:571)
i_slint_core::properties::Property<T>::get (/Users/simon/src/slint/internal/core/properties.rs:777)
<field_offset::FieldOffset<Item,i_slint_core::properties::Property<T>,field_offset::AllowPin> as i_slint_core::rtti::PropertyInfo<Item,Value>>::get (/Users/simon/src/slint/internal/core/rtti.rs:118)
slint_interpreter::eval::load_property_helper (/Users/simon/src/slint/internal/interpreter/eval.rs:1102)
slint_interpreter::eval::eval_expression (/Users/simon/src/slint/internal/interpreter/eval.rs:376)
slint_interpreter::dynamic_component::make_binding_eval_closure::{{closure}} (/Users/simon/src/slint/internal/interpreter/dynamic_component.rs:1249)
<alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call (@<alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call:13)
<i_slint_core::rtti::MaybeAnimatedPropertyInfoWrapper<Item,i_slint_core::properties::Property<T>> as i_slint_core::rtti::PropertyInfo<Item,Value>>::set_binding::set_binding_impl::{{closure}} (/Users/simon/src/slint/internal/core/rtti.rs:209)
<F as i_slint_core::properties::Binding<T>>::evaluate (/Users/simon/src/slint/internal/core/properties.rs:693)
i_slint_core::properties::Property<T>::set_binding::{{closure}} (/Users/simon/src/slint/internal/core/properties.rs:886)
<F as i_slint_core::properties::BindingCallable>::evaluate (/Users/simon/src/slint/internal/core/properties.rs:290)
i_slint_core::properties::alloc_binding_holder::evaluate::{{closure}} (/Users/simon/src/slint/internal/core/properties.rs:393)
i_slint_core::properties::CURRENT_BINDING::<impl i_slint_core::properties::CURRENT_BINDING>::set (/Users/simon/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scoped-tls-hkt-0.1.2/src/lib.rs:264)
i_slint_core::properties::alloc_binding_holder::evaluate (/Users/simon/src/slint/internal/core/properties.rs:392)
i_slint_core::properties::PropertyHandle::update::{{closure}} (/Users/simon/src/slint/internal/core/properties.rs:576)
i_slint_core::properties::PropertyHandle::access (/Users/simon/src/slint/internal/core/properties.rs:481)
i_slint_core::properties::PropertyHandle::update (/Users/simon/src/slint/internal/core/properties.rs:571)
i_slint_core::properties::Property<T>::get (/Users/simon/src/slint/internal/core/properties.rs:777)
i_slint_core::items::text::TextInput::y (/Users/simon/src/slint/internal/core/items/text.rs:214)
<i_slint_core::items::text::TextInput as i_slint_core::items::Item_vtable_mod::Item>::geometry (/Users/simon/src/slint/internal/core/items/text.rs:262)
i_slint_core::items::TextInputVTable::geometry (/Users/simon/src/slint/internal/core/items.rs:106)
i_slint_core::items::Item_vtable_mod::ItemTO::geometry (/Users/simon/src/slint/internal/core/items.rs:106)
i_slint_core::item_tree::ItemRc::is_visible (/Users/simon/src/slint/internal/core/item_tree.rs:139)
i_slint_core::window::WindowInner::move_focus (/Users/simon/src/slint/internal/core/window.rs:605)
i_slint_core::window::WindowInner::set_focus_item (/Users/simon/src/slint/internal/core/window.rs:535)
slint_interpreter::eval::call_builtin_function::{{closure}} (/Users/simon/src/slint/internal/interpreter/eval.rs:520)
slint_interpreter::dynamic_component::InstanceRef::access_window (/Users/simon/src/slint/internal/interpreter/dynamic_component.rs:1950)
slint_interpreter::eval::call_builtin_function (/Users/simon/src/slint/internal/interpreter/eval.rs:519)
slint_interpreter::eval::eval_expression (/Users/simon/src/slint/internal/interpreter/eval.rs:223)
slint_interpreter::eval::eval_expression (/Users/simon/src/slint/internal/interpreter/eval.rs:207)
slint_interpreter::dynamic_component::ErasedComponentBox::run_setup_code (/Users/simon/src/slint/internal/interpreter/dynamic_component.rs:1556)
<slint_interpreter::dynamic_component::ErasedComponentBox as i_slint_core::model::RepeatedComponent>::init (/Users/simon/src/slint/internal/interpreter/dynamic_component.rs:120)
i_slint_core::model::Repeater<C>::ensure_updated_impl (/Users/simon/src/slint/internal/core/model.rs:913)
i_slint_core::model::Repeater<C>::ensure_updated (/Users/simon/src/slint/internal/core/model.rs:887)
slint_interpreter::eval_layout::box_layout_data (/Users/simon/src/slint/internal/interpreter/eval_layout.rs:201)
slint_interpreter::eval_layout::compute_layout_info (/Users/simon/src/slint/internal/interpreter/eval_layout.rs:56)
slint_interpreter::eval::eval_expression (/Users/simon/src/slint/internal/interpreter/eval.rs:388)
slint_interpreter::dynamic_component::make_binding_eval_closure::{{closure}} (/Users/simon/src/slint/internal/interpreter/dynamic_component.rs:1249)
<alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call (@<alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call:13)
<field_offset::FieldOffset<Item,i_slint_core::properties::Property<T>,field_offset::AllowPin> as i_slint_core::rtti::PropertyInfo<Item,Value>>::set_binding::{{closure}} (/Users/simon/src/slint/internal/core/rtti.rs:143)
<F as i_slint_core::properties::Binding<T>>::evaluate (/Users/simon/src/slint/internal/core/properties.rs:693)
i_slint_core::properties::Property<T>::set_binding::{{closure}} (/Users/simon/src/slint/internal/core/properties.rs:886)
<F as i_slint_core::properties::BindingCallable>::evaluate (/Users/simon/src/slint/internal/core/properties.rs:290)
i_slint_core::properties::alloc_binding_holder::evaluate::{{closure}} (/Users/simon/src/slint/internal/core/properties.rs:393)
i_slint_core::properties::CURRENT_BINDING::<impl i_slint_core::properties::CURRENT_BINDING>::set (/Users/simon/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scoped-tls-hkt-0.1.2/src/lib.rs:264)
i_slint_core::properties::alloc_binding_holder::evaluate (/Users/simon/src/slint/internal/core/properties.rs:392)
i_slint_core::properties::PropertyHandle::update::{{closure}} (/Users/simon/src/slint/internal/core/properties.rs:576)
i_slint_core::properties::PropertyHandle::access (/Users/simon/src/slint/internal/core/properties.rs:481)
i_slint_core::properties::PropertyHandle::update (/Users/simon/src/slint/internal/core/properties.rs:571)
i_slint_core::properties::Property<T>::get (/Users/simon/src/slint/internal/core/properties.rs:777)
<field_offset::FieldOffset<Item,i_slint_core::properties::Property<T>,field_offset::AllowPin> as i_slint_core::rtti::PropertyInfo<Item,Value>>::get (/Users/simon/src/slint/internal/core/rtti.rs:118)
slint_interpreter::eval::load_property_helper (/Users/simon/src/slint/internal/interpreter/eval.rs:1102)
slint_interpreter::eval::eval_expression (/Users/simon/src/slint/internal/interpreter/eval.rs:153)
slint_interpreter::eval::eval_expression (/Users/simon/src/slint/internal/interpreter/eval.rs:233)
slint_interpreter::dynamic_component::make_binding_eval_closure::{{closure}} (/Users/simon/src/slint/internal/interpreter/dynamic_component.rs:1249)
<alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call (@<alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call:13)
<field_offset::FieldOffset<Item,i_slint_core::properties::Property<T>,field_offset::AllowPin> as i_slint_core::rtti::PropertyInfo<Item,Value>>::set_binding::{{closure}} (/Users/simon/src/slint/internal/core/rtti.rs:143)
<F as i_slint_core::properties::Binding<T>>::evaluate (/Users/simon/src/slint/internal/core/properties.rs:693)
i_slint_core::properties::Property<T>::set_binding::{{closure}} (/Users/simon/src/slint/internal/core/properties.rs:886)
<F as i_slint_core::properties::BindingCallable>::evaluate (/Users/simon/src/slint/internal/core/properties.rs:290)
i_slint_core::properties::alloc_binding_holder::evaluate::{{closure}} (/Users/simon/src/slint/internal/core/properties.rs:393)
i_slint_core::properties::CURRENT_BINDING::<impl i_slint_core::properties::CURRENT_BINDING>::set (/Users/simon/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scoped-tls-hkt-0.1.2/src/lib.rs:264)
i_slint_core::properties::alloc_binding_holder::evaluate (/Users/simon/src/slint/internal/core/properties.rs:392)
i_slint_core::properties::PropertyHandle::update::{{closure}} (/Users/simon/src/slint/internal/core/properties.rs:576)
i_slint_core::properties::PropertyHandle::access (/Users/simon/src/slint/internal/core/properties.rs:481)
i_slint_core::properties::PropertyHandle::update (/Users/simon/src/slint/internal/core/properties.rs:571)
i_slint_core::properties::Property<T>::get (/Users/simon/src/slint/internal/core/properties.rs:777)
<field_offset::FieldOffset<Item,i_slint_core::properties::Property<T>,field_offset::AllowPin> as i_slint_core::rtti::PropertyInfo<Item,Value>>::get (/Users/simon/src/slint/internal/core/rtti.rs:118)
slint_interpreter::eval::load_property_helper (/Users/simon/src/slint/internal/interpreter/eval.rs:1102)
slint_interpreter::eval::eval_expression (/Users/simon/src/slint/internal/interpreter/eval.rs:153)
slint_interpreter::eval::eval_expression (/Users/simon/src/slint/internal/interpreter/eval.rs:233)
slint_interpreter::dynamic_component::make_binding_eval_closure::{{closure}} (/Users/simon/src/slint/internal/interpreter/dynamic_component.rs:1249)
<alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call (@<alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call:13)
<field_offset::FieldOffset<Item,i_slint_core::properties::Property<T>,field_offset::AllowPin> as i_slint_core::rtti::PropertyInfo<Item,Value>>::set_binding::{{closure}} (/Users/simon/src/slint/internal/core/rtti.rs:143)
<F as i_slint_core::properties::Binding<T>>::evaluate (/Users/simon/src/slint/internal/core/properties.rs:693)
i_slint_core::properties::Property<T>::set_binding::{{closure}} (/Users/simon/src/slint/internal/core/properties.rs:886)
<F as i_slint_core::properties::BindingCallable>::evaluate (/Users/simon/src/slint/internal/core/properties.rs:290)
i_slint_core::properties::alloc_binding_holder::evaluate::{{closure}} (/Users/simon/src/slint/internal/core/properties.rs:393)
i_slint_core::properties::CURRENT_BINDING::<impl i_slint_core::properties::CURRENT_BINDING>::set (/Users/simon/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scoped-tls-hkt-0.1.2/src/lib.rs:264)
i_slint_core::properties::alloc_binding_holder::evaluate (/Users/simon/src/slint/internal/core/properties.rs:392)
i_slint_core::properties::PropertyHandle::update::{{closure}} (/Users/simon/src/slint/internal/core/properties.rs:576)
i_slint_core::properties::PropertyHandle::access (/Users/simon/src/slint/internal/core/properties.rs:481)
i_slint_core::properties::PropertyHandle::update (/Users/simon/src/slint/internal/core/properties.rs:571)
i_slint_core::properties::Property<T>::get (/Users/simon/src/slint/internal/core/properties.rs:777)
<field_offset::FieldOffset<Item,i_slint_core::properties::Property<T>,field_offset::AllowPin> as i_slint_core::rtti::PropertyInfo<Item,Value>>::get (/Users/simon/src/slint/internal/core/rtti.rs:118)
slint_interpreter::eval::load_property_helper (/Users/simon/src/slint/internal/interpreter/eval.rs:1102)
slint_interpreter::eval::load_property (/Users/simon/src/slint/internal/interpreter/eval.rs:1086)
slint_interpreter::eval_layout::get_layout_info (/Users/simon/src/slint/internal/interpreter/eval_layout.rs:313)
slint_interpreter::dynamic_component::layout_info (/Users/simon/src/slint/internal/interpreter/dynamic_component.rs:1591)
i_slint_core::component::Component_vtable_mod::ComponentTO::layout_info (/Users/simon/src/slint/internal/core/component.rs:40)
<slint_interpreter::dynamic_component::ErasedComponentBox as i_slint_core::component::Component_vtable_mod::Component>::layout_info (/Users/simon/src/slint/internal/interpreter/dynamic_component.rs:171)
slint_interpreter::dynamic_component::COMPONENT_BOX_VT::layout_info (/Users/simon/src/slint/internal/core/component.rs:40)
i_slint_core::component::Component_vtable_mod::ComponentTO::layout_info (/Users/simon/src/slint/internal/core/component.rs:40)
i_slint_core::window::WindowInner::update_window_properties::{{closure}} (/Users/simon/src/slint/internal/core/window.rs:676)
i_slint_core::properties::CURRENT_BINDING::<impl i_slint_core::properties::CURRENT_BINDING>::set (/Users/simon/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scoped-tls-hkt-0.1.2/src/lib.rs:264)
i_slint_core::properties::PropertyTracker<DirtyHandler>::evaluate_as_dependency_root (/Users/simon/src/slint/internal/core/properties.rs:1308)
i_slint_core::window::WindowInner::update_window_properties (/Users/simon/src/slint/internal/core/window.rs:668)
i_slint_core::window::WindowInner::show (/Users/simon/src/slint/internal/core/window.rs:723)
i_slint_core::api::Window::show (/Users/simon/src/slint/internal/core/api.rs:372)
<slint_interpreter::api::ComponentInstance as i_slint_core::api::ComponentHandle>::show (/Users/simon/src/slint/internal/interpreter/api.rs:1082)
<slint_interpreter::api::ComponentInstance as i_slint_core::api::ComponentHandle>::run (/Users/simon/src/slint/internal/interpreter/api.rs:1090)
slint_viewer::main (/Users/simon/src/slint/tools/viewer/main.rs:114)
core::ops::function::FnOnce::call_once (@core::ops::function::FnOnce::call_once:8)
std::sys_common::backtrace::__rust_begin_short_backtrace (@std::sys_common::backtrace::__rust_begin_short_backtrace:8)
std::rt::lang_start::{{closure}} (@std::rt::lang_start::{{closure}}:9)
std::panicking::try (@std::panicking::try:12)
std::rt::lang_start_internal (@std::rt::lang_start_internal:18)
std::rt::lang_start (@std::rt::lang_start:18)
main (@main:10)
start (@start:423)
@tronical tronical added bug Something isn't working a:models&views The implementation of the `for` and ListView (mO,bF) labels Aug 3, 2023
tronical added a commit that referenced this issue Aug 3, 2023
…ers repeater traversal

Don't call init() while mutably borrowing the repeater's inner.

Fixes #3214
tronical added a commit that referenced this issue Mar 8, 2024
…ers repeater traversal

Don't call init() while mutably borrowing the repeater's inner.

Fixes #3214
tronical added a commit that referenced this issue Mar 8, 2024
…ers repeater traversal

Don't call init() while mutably borrowing the repeater's inner.

Fixes #3214
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:models&views The implementation of the `for` and ListView (mO,bF) bug Something isn't working
Projects
None yet
1 participant