slint-ui/slint · error
no simulated native drag in flight
Error message
no simulated native drag in flight
What it means
The testing backend's `deliver_native_drag` requires a simulated native drag to have been started beforehand; it reads drag data from an internal `native_drag` cell. If no drag is in flight the cell is `None` and the backend panics.
Solutions
- Start the simulated native drag (drag-enter/press with drag data) before calling move or drop
- Ensure each drop has exactly one preceding drag start; a second drop after the drag was consumed also panics
- Reset or recreate the test backend/window between drag scenarios
Example fix
// before backend.simulate_native_drop(&window, pos); // panics: no drag in flight // after backend.simulate_native_drag_enter(&window, drag_data); backend.simulate_native_drag_move(&window, pos); backend.simulate_native_drop(&window, pos);
Defensive patterns
Strategy: validation
Validate before calling
// ensure a drag was started before move/drop in your test harness
fn ensure_drag_in_flight(backend: &TestingBackend, started: &mut bool) {
assert!(*started, "call drag-enter/start before move or drop");
} Try / catch
std::panic::catch_unwind(|| backend.simulate_native_drop(&window, pos))
.map_err(|_| anyhow!("no native drag in flight: start drag first"))?; Prevention
- Always pair each drag move/drop with a preceding drag start
- Track drag lifecycle state in your test harness (started/moved/dropped)
- Reset the backend between independent drag scenarios
When it happens
Trigger: Calling `simulate_native_drag_move()` or `simulate_native_drop()` without a prior call that starts a simulated native drag (e.g. `simulate_native_drag_enter`/equivalent start API) on the testing backend.
Common situations: Test scripts that skip the drag-start step; reordering refactored test steps so drop/move happens after the drag was already consumed by a previous drop; writing only a 'drop' simulation assuming it stands alone.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- a setter belongs to a field
- an identifier
- binding was of the wrong type
- C++: NativeWindowHandle created with null hwnd
- C++: NativeWindowHandle created with null xcb window handle
AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16).
Data as JSON: /api/errors/4088cd629ec3926f.
Report an issue: GitHub.
Appendix: source
Thrown at internal/backends/testing/testing_backend.rs:416
/// the final negotiated action.
pub fn simulate_native_drop(
&self,
target: &i_slint_core::api::Window,
position: LogicalPosition,
) -> DragAction {
let action = self.deliver_native_drag(target, position, true);
WindowInner::from_pub(&self.window).report_drag_finished(action);
action
}
fn deliver_native_drag(
&self,
target: &i_slint_core::api::Window,
position: LogicalPosition,
drop: bool,
) -> DragAction {
let (data, allowed) =
self.native_drag.borrow().clone().expect("no simulated native drag in flight");
let mut event = DropEvent::default();
event.data = data;
event.position = position;
event.proposed_action =
i_slint_core::items::compute_proposed_action(Default::default(), allowed);
let event = if drop {
BackendDragEvent::Drop { event, allowed }
} else {
BackendDragEvent::Move { event, allowed }
};
WindowInner::from_pub(target).process_drag_event(event).unwrap_or(DragAction::None)
}
}
impl WindowAdapterInternal for TestingWindow {
fn input_method_request(&self, request: i_slint_core::window::InputMethodRequest) {
self.ime_requests.borrow_mut().push(request)
}View on GitHub (pinned to bb937076de)