From 2e3b0e8a99eead1b3e8f731e7a7eb67761ec566a Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 8 Apr 2021 10:44:33 -0500 Subject: Fix: Dragging a modifier to the same index recalculates modifier stack The fix is to simply check if the final index is the same as the start index and not call the "reorder" callback in that case. --- source/blender/editors/interface/interface_panel.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/blender/editors/interface/interface_panel.c') diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 8922babc9b8..6505a7cd76a 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -437,15 +437,21 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr /* Find how many instanced panels with this context string. */ int list_panels_len = 0; + int start_index = -1; LISTBASE_FOREACH (const Panel *, panel, ®ion->panels) { if (panel->type) { if (panel->type->flag & PANEL_TYPE_INSTANCED) { if (panel_type_context_poll(region, panel->type, context)) { + if (panel == drag_panel) { + BLI_assert(start_index == -1); /* This panel should only appear once. */ + start_index = list_panels_len; + } list_panels_len++; } } } } + BLI_assert(start_index != -1); /* The drag panel should definitely be in the list. */ /* Sort the matching instanced panels by their display order. */ PanelSort *panel_sort = MEM_callocN(list_panels_len * sizeof(*panel_sort), __func__); @@ -472,6 +478,11 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr MEM_freeN(panel_sort); + if (move_to_index == start_index) { + /* In this case, the reorder was not changed, so don't do any updates or call the callback. */ + return; + } + /* Set the bit to tell the interface to instanced the list. */ drag_panel->flag |= PNL_INSTANCED_LIST_ORDER_CHANGED; -- cgit v1.2.3