slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.55k stars 603 forks source link

Panic while upgrading component in binding #6262

Closed jturcotte closed 1 month ago

jturcotte commented 1 month ago

Repro steps:

I tried to do it with a .slint file instead of through the slint! macro, but it didn't seem to crash.

use slint::slint;

slint! {
    export component Window inherits Window {
    }
}
fn main() {
    Window::new().unwrap().run().unwrap();
}
thread 'main' panicked at /home/runner/work/slint/slint/api/rs/slint/private_unstable_api.rs:60:89:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: i_slint_core::properties::alloc_binding_holder::evaluate
   5: i_slint_core::properties::Property<T>::get
   6: i_slint_core::properties::alloc_binding_holder::evaluate
   7: i_slint_core::properties::Property<T>::get
   8: i_slint_core::items::FocusScopeVTable::focus_event
   9: i_slint_core::window::WindowInner::take_focus_item
  10: i_slint_core::window::WindowInner::set_focus_item
  11: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerComponent_empty_303 as i_slint_core::model::RepeatedItemTree>::init
  12: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerComponent_empty_300 as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item::visit_dynamic
  13: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerComponent_empty_300 as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item
  14: i_slint_core::input::send_mouse_event_to_item
  15: i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitorVTable::new::visit_item
  16: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerComponent_empty_300 as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item
  17: slint_lsp::preview::ui::slint_generatedPreviewUi::InnerPreviewView_root_283::visit_dynamic_children
  18: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerComponent_rectangle_9 as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item
  19: i_slint_core::input::send_mouse_event_to_item
  20: i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitorVTable::new::visit_item
  21: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerComponent_rectangle_9 as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item
  22: i_slint_core::input::send_mouse_event_to_item
  23: i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitorVTable::new::visit_item
  24: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerComponent_rectangle_9 as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item
  25: i_slint_core::input::send_mouse_event_to_item
  26: i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitorVTable::new::visit_item
  27: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerComponent_rectangle_9 as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item
  28: i_slint_core::input::send_mouse_event_to_item
  29: i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitorVTable::new::visit_item
  30: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerComponent_rectangle_9 as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item
  31: i_slint_core::input::send_mouse_event_to_item
  32: i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitorVTable::new::visit_item
  33: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerComponent_rectangle_9 as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item
  34: i_slint_core::input::send_mouse_event_to_item
  35: i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitorVTable::new::visit_item
  36: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerComponent_rectangle_9 as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item
  37: i_slint_core::input::send_mouse_event_to_item
  38: i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitorVTable::new::visit_item
  39: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerComponent_rectangle_9 as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item
  40: i_slint_core::input::send_mouse_event_to_item
  41: i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitorVTable::new::visit_item
  42: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerComponent_rectangle_9 as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item
  43: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerPreviewUi as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item::visit_dynamic
  44: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerPreviewUi as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item
  45: i_slint_core::input::send_mouse_event_to_item
  46: i_slint_core::input::process_mouse_input
  47: i_slint_core::window::WindowInner::process_mouse_input
  48: <i_slint_backend_winit::event_loop::ActiveEventLoopSetterDuringEventProcessing<Handler> as winit::application::ApplicationHandler<Event>>::window_event
  49: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  50: winit::platform_impl::linux::wayland::event_loop::EventLoop<T>::pump_events
  51: <i_slint_backend_winit::Backend as i_slint_core::platform::Platform>::run_event_loop
  52: slint_lsp::main
ogoffart commented 1 month ago

I cannot reproduce the problem but the backtrace indicate this happens when changing focus due to an event. It is possible that this event might have destroyed a component and some binding still hold weak pointer to it.

jturcotte commented 1 month ago

Maybe this helps, otherwise please let me know I could gather more information.

rec

hunger commented 1 month ago

FYI: #6347 fixes a panic that was found by Olivier while looking into this bug.