emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
22.41k stars 1.61k forks source link

dnd_drag_source cannot include any Frames #4604

Open Auvrae opened 5 months ago

Auvrae commented 5 months ago

Describe the bug Using the latest master branch, doing drag n drop operations with a group or anything that instantiates a new Frame, causes a crash. The exception is that you can have one dnd_drag_source that includes multiple Frames, otherwise it will crash when you attempt to drag one. egui/crates/egui/src/widget_rect.rs:142:17: Widget changed layer_id during the frame

This does not occur in latest release version: 0.27.2

To Reproduce Steps to reproduce the behavior:

  1. Download the Drag and Drop example.
  2. Change all ui.label("__"); to ui.group(|ui| { ui.label("___"} );
  3. Click to start dragging. Immediate crash.

Expected behavior Drag any widget or widget group.

Desktop (please complete the following information):

0.27.2 https://github.com/emilk/egui/assets/19319115/00ff2cc5-c118-428b-81c8-393474d42e89

Latest commit: image

Auvrae commented 5 months ago

After digging around in the source code. It appears this crash is caused by a debug assertion that's only active on non-release builds.

debug_assert!( existing.layer_id == widget_rect.layer_id, "Widget changed layer_id during the frame" );

I'll leave it open if we feel like this needs to be removed before the next release, for now I'm removing the assertion from my local source so I don't have to build it as release while I'm developing..