meta inception - getting selected item from an item in the preview window
Bug Description
I am working on adding gradients to the preview window in slint live-preview app. to reproduce:
without compiling preview PreviewUi from main.slint in tools/lsp/ui/components then open properties window of the previewed app (not the actual preview window) then select the actual preview window selection tool then try to select something in the previewed properties
thread 'main' panicked at internal/interpreter/dynamic_item_tree.rs:1886:45:
get_item_ref called on dynamic tree
stack backtrace:
0: 0x103023a98 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h6e25c13836847e70
1: 0x102879e44 - core::fmt::write::h37cdb50ab8af3d55
2: 0x103021d84 - std::io::Write::write_fmt::hd4c273f34c4c0a33
3: 0x103023938 - std::sys::backtrace::BacktraceLock::print::h1df7364dde63dc75
4: 0x1030225f4 - std::panicking::default_hook::hf65fd28e95db7176
5: 0x102fc4f50 - slint_lsp::main::{{closure}}::heafd4eff81c46e18
6: 0x103021bac - std::panicking::rust_panic_with_hook::hc9e2ec2a12b10e12
7: 0x10304c7e4 - std::panicking::begin_panic_handler::{{closure}}::h3b6449e2eb83bf4c
8: 0x10304c77c - std::sys::backtrace::__rust_end_short_backtrace::h38d85099ddd107a3
9: 0x10304d200 - _rust_begin_unwind
10: 0x1035de794 - core::panicking::panic_fmt::hd4003258f6ab7b29
11: 0x102d47dec - slint_interpreter::dynamic_item_tree::COMPONENT_BOX_VT::get_item_ref::h023c67a1a387b62a
12: 0x102b5ae68 - i_slint_core::item_tree::ItemRc::absolute_clip_rect_and_geometry::h5acfe85af05273cf
13: 0x102d67058 - slint_interpreter::highlight::fill_highlight_data::h954053849b4782a6
14: 0x102d67200 - slint_interpreter::highlight::fill_highlight_data::h954053849b4782a6
15: 0x102d67464 - slint_interpreter::highlight::element_positions::h7f9e02af7b0ce050
16: 0x102fe4610 - slint_lsp::preview::element_selection::collect_all_element_nodes_covering_impl::h03814485b8f6e8ea
17: 0x102fe45d4 - slint_lsp::preview::element_selection::collect_all_element_nodes_covering_impl::h03814485b8f6e8ea
18: 0x102fe45d4 - slint_lsp::preview::element_selection::collect_all_element_nodes_covering_impl::h03814485b8f6e8ea
19: 0x102fe45d4 - slint_lsp::preview::element_selection::collect_all_element_nodes_covering_impl::h03814485b8f6e8ea
20: 0x102fe45d4 - slint_lsp::preview::element_selection::collect_all_element_nodes_covering_impl::h03814485b8f6e8ea
21: 0x102fe45d4 - slint_lsp::preview::element_selection::collect_all_element_nodes_covering_impl::h03814485b8f6e8ea
22: 0x102fe45d4 - slint_lsp::preview::element_selection::collect_all_element_nodes_covering_impl::h03814485b8f6e8ea
23: 0x102fe45d4 - slint_lsp::preview::element_selection::collect_all_element_nodes_covering_impl::h03814485b8f6e8ea
24: 0x102fe45d4 - slint_lsp::preview::element_selection::collect_all_element_nodes_covering_impl::h03814485b8f6e8ea
25: 0x102fe45d4 - slint_lsp::preview::element_selection::collect_all_element_nodes_covering_impl::h03814485b8f6e8ea
26: 0x102fe45d4 - slint_lsp::preview::element_selection::collect_all_element_nodes_covering_impl::h03814485b8f6e8ea
27: 0x102fe45d4 - slint_lsp::preview::element_selection::collect_all_element_nodes_covering_impl::h03814485b8f6e8ea
28: 0x102fe43dc - slint_lsp::preview::element_selection::collect_all_element_nodes_covering::h030a9b02f9d31478
29: 0x102fe4938 - slint_lsp::preview::element_selection::select_element_at::h325f059749e2bdcd
30: 0x10266bf9c - core::ops::function::FnOnce::call_once::h7156fe49e70b4839
31: 0x102ac4598 - i_slint_core::items::TouchAreaVTable::input_event::he55c2129f76d4b1a
32: 0x102b06b3c - i_slint_core::window::WindowInner::process_mouse_input::h59ff1c881d78b48c
33: 0x1028cba38 - <i_slint_backend_winit::event_loop::ActiveEventLoopSetterDuringEventProcessing<Handler> as winit::application::ApplicationHandler<Event>>::window_event::h41af15b12352b49c
34: 0x1028db98c - winit::platform_impl::macos::event_loop::map_user_event::{{closure}}::h97ca4d4aff17d42e
35: 0x10311f1b8 - winit::platform_impl::macos::event_handler::EventHandler::handle_event::hcec230be4a7e66f3
36: 0x1031192bc - winit::platform_impl::macos::app_state::ApplicationDelegate::maybe_queue_event::h4897a9f3f2dcc9e2
37: 0x103116750 - winit::platform_impl::macos::view::WinitView::mouse_click::h6426b660b858c35d
38: 0x18dcd157c -
Reproducible Code (if applicable)
Environment Details
- Slint Version: nightly
- Platform/OS: mac
- Programming Language: rust
- Backend/Renderer: don't know. assuming hardware
Product Impact
No response
I can reproduce this.
Its strange: In interpreter/highlight-rs we check that the element is not repeated and take the execution path that sees no repeater_path. Then we take the Element's item_index and access that. This panics as the Item is a Dynamic Tree node.
I wonder how we end up pointing to a dynamic item tree node for an element that we think is not dynamic? Maybe due to the ComponentFactory in the mix? I need to think about this a bit deeper.