diff options
author | Hans Goudey <h.goudey@me.com> | 2021-04-08 18:44:33 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-04-08 18:44:33 +0300 |
commit | 2e3b0e8a99eead1b3e8f731e7a7eb67761ec566a (patch) | |
tree | 199fb78f2970e47fbc81b40f6ef53ed3a215ef84 | |
parent | c6ff722a1fcc632eacebcfc94417df466742ce5f (diff) |
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.
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 11 |
1 files changed, 11 insertions, 0 deletions
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; |