slint-ui / slint

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

main thread panicked when pressing / moving a button added to a component #5642

Closed szecket closed 1 month ago

szecket commented 1 month ago

running on mac in VS Code and just testing nightly for recent changes to drag/drop on full area by @tronical v2024.7.1717

added a button to card.slint in svg example moved the button around to different areas changed attributes in properties moved it interactively crashed


called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[Info  - 3:48:55 PM] Connection to server got closed. Server will restart.
true
The Slint Language Server crashed. This is a bug.```
szecket commented 1 month ago

rust backtrace provided:


   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: slint_lsp::preview::drop_location::find_filtered_location
   5: slint_lsp::preview::can_move_selected_element
   6: i_slint_core::callbacks::Callback<Arg,Ret>::set_handler::{{closure}}
   7: core::ops::function::FnOnce::call_once
   8: i_slint_core::callbacks::Callback<Arg,Ret>::set_handler::{{closure}}
   9: core::ops::function::FnOnce::call_once
  10: i_slint_core::callbacks::Callback<Arg,Ret>::set_handler::{{closure}}
  11: core::ops::function::FnOnce::call_once
  12: i_slint_core::items::TouchAreaVTable::input_event
  13: i_slint_core::window::WindowInner::process_mouse_input
  14: <i_slint_backend_winit::event_loop::ActiveEventLoopSetterDuringEventProcessing<Handler> as winit::application::ApplicationHandler<Event>>::window_event
  15: winit::platform_impl::macos::event_loop::map_user_event::{{closure}}
  16: winit::platform_impl::macos::event_handler::EventHandler::handle_event
  17: winit::platform_impl::macos::app_state::ApplicationDelegate::maybe_queue_event
  18: winit::platform_impl::macos::view::WinitView::mouse_motion
  19: <unknown>
  20: <unknown>
  21: <unknown>
  22: <unknown>
  23: winit::platform_impl::macos::app::WinitApplication::send_event
  24: <unknown>
  25: <unknown>
  26: <i_slint_backend_winit::Backend as i_slint_core::platform::Platform>::run_event_loop
  27: slint_lsp::main
szecket commented 1 month ago

tried another much more direct reproducible test in that file. placed a button inside image. select said button and drag it out of the image.
as it drags out onto toucharea I get the crash

tronical commented 1 month ago

There are, as it looks like, two crashes. The moving around of the button triggering the panic in parser.rs, and the unwrap in slint_lsp::preview::drop_location::find_filtered_location failing.

ogoffart commented 1 month ago

I think that's the same panic actually. find_filtered_location inline calls find_element_to_drop_into then is_recursive_inclusion which calls functions declared in the parser which causes the panic.

I'll add #[track_caller] so that bugs in the preview won't be mistaken with bug in the parser 😸