Fix #144335: Collection asset drag-and-drop creates two undo operations

This fixes https://projects.blender.org/blender/blender/issues/144335 by surrounding the drag-and-drop handling functionality in an undo group.

<video src="attachments/b8ddcb80-cda2-4f5e-83dd-4736dbe7eddd" title="Screencast_20250815_161525.webm" controls></video>

Pull Request: https://projects.blender.org/blender/blender/pulls/144630
This commit is contained in:
Colin Basnett
2025-08-20 23:24:51 +02:00
committed by Colin Basnett
parent 1d9bd460fc
commit ee43c4c782

View File

@@ -3510,6 +3510,9 @@ static eHandlerActionFlag wm_handlers_do_intern(bContext *C,
LISTBASE_FOREACH (wmDropBox *, drop, handler->dropboxes) {
/* Other drop custom types allowed. */
if (event->custom == EVT_DATA_DRAGDROP) {
/* Drop handlers can perform multiple operations (e.g., collection drag-and-drop),
* but we want to treat it as a single operation. */
ED_undo_group_begin(C);
ListBase *lb = (ListBase *)event->customdata;
LISTBASE_FOREACH_MUTABLE (wmDrag *, drag, lb) {
if (drop->poll(C, drag, event)) {
@@ -3553,6 +3556,7 @@ static eHandlerActionFlag wm_handlers_do_intern(bContext *C,
}
/* Always exit all drags on a drop event, even if poll didn't succeed. */
wm_drags_exit(wm, win);
ED_undo_group_end(C);
}
}
}