DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
18.5k stars 704 forks source link

Crash when using ondragstart #2328

Closed jeancf closed 1 week ago

jeancf commented 2 weeks ago

Problem

Trying to drag an Element to which an ondragstart event handler has been added results in a crash of the application.

Steps To Reproduce

Steps to reproduce the behavior:

main.css


#![allow(non_snake_case)]

use dioxus::prelude::*; use log::LevelFilter;

fn main() { // Init debug dioxus_logger::init(LevelFilter::Debug).expect("failed to init logger");

dioxus::launch(App);

}

[component]

fn App() -> Element { rsx! { div { ondragstart: move |ev| { log::debug!("{:?}", ev); }, "DIV" } } }

- Launch with `dx serve`
- Select the word `DIV`
- Try to drag it
- Nothing appears in the debug log and crash:

thread 'main' panicked at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dioxus-desktop-0.5.1/src/app.rs:301:60: called Option::unwrap() on a None value

stack backtrace: 0: rust_begin_unwind at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:647:5 1: core::panicking::panic_fmt at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:72:14 2: core::panicking::panic at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:144:5 3: core::option::unwrap_failed at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/option.rs:1978:5 4: core::option::Option::unwrap at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/option.rs:931:21 5: dioxus_desktop::app::App::handle_user_event_msg at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dioxus-desktop-0.5.1/src/app.rs:301:38 6: dioxus_desktop::launch::launch_virtual_dom_blocking::{{closure}} at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dioxus-desktop-0.5.1/src/launch.rs:55:45 7: tao::platform_impl::platform::event_loop::EventLoop::run_return::{{closure}} at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.26.2/src/platform_impl/linux/event_loop.rs:1005:24 8: glib::main_context::::with_thread_default at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/glib-0.18.5/src/main_context.rs:154:12 9: tao::platform_impl::platform::event_loop::EventLoop::run_return at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.26.2/src/platform_impl/linux/event_loop.rs:929:5 10: tao::platform_impl::platform::event_loop::EventLoop::run at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.26.2/src/platform_impl/linux/event_loop.rs:883:21 11: tao::event_loop::EventLoop::run at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tao-0.26.2/src/event_loop.rs:211:5 12: dioxus_desktop::launch::launch_virtual_dom_blocking at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dioxus-desktop-0.5.1/src/launch.rs:17:5 13: dioxus_desktop::launch::launch_virtual_dom::{{closure}} at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dioxus-desktop-0.5.1/src/launch.rs:76:13 14: <tokio::task::unconstrained::Unconstrained as core::future::future::Future>::poll::{{closure}} at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/task/unconstrained.rs:25:57 15: tokio::runtime::coop::with_budget at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/coop.rs:107:5 16: tokio::runtime::coop::with_unconstrained at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/coop.rs:80:5 17: <tokio::task::unconstrained::Unconstrained as core::future::future::Future>::poll at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/task/unconstrained.rs:25:13 18: tokio::runtime::park::CachedParkThread::block_on::{{closure}} at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/park.rs:281:63 19: tokio::runtime::coop::with_budget at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/coop.rs:107:5 20: tokio::runtime::coop::budget at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/coop.rs:73:5 21: tokio::runtime::park::CachedParkThread::block_on at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/park.rs:281:31 22: tokio::runtime::context::blocking::BlockingRegionGuard::block_on at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/context/blocking.rs:66:9 23: tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}} at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/scheduler/multi_thread/mod.rs:87:13 24: tokio::runtime::context::runtime::enter_runtime at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/context/runtime.rs:65:16 25: tokio::runtime::scheduler::multi_thread::MultiThread::block_on at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/scheduler/multi_thread/mod.rs:86:9 26: tokio::runtime::runtime::Runtime::block_on at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.37.0/src/runtime/runtime.rs:351:45 27: dioxus_desktop::launch::launch_virtual_dom at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dioxus-desktop-0.5.1/src/launch.rs:71:5 28: dioxus_desktop::launch::launch at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dioxus-desktop-0.5.1/src/launch.rs:95:5 29: dioxus::launch::LaunchBuilder<Cfg,ContextFn>::launch at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dioxus-0.5.1/src/launch.rs:171:9 30: dioxus::launch::launch at /home/jeancf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dioxus-0.5.1/src/launch.rs:280:5 31: graph::main at ./src/main.rs:10:5 32: core::ops::function::FnOnce::call_once at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/ops/function.rs:250:5



**Expected behavior**

No crash and content of `DragData` printed in the log.

**Environment:**
 - Dioxus version: 0.5.1
 - Rust version: 1.77.2
 - OS info: Manjaro Linux
 - App platform: desktop