[Bf-blender-cvs] [2e3b0e8a99e] master: Fix: Dragging a modifier to the same index recalculates modifier stack

Hans Goudey noreply at git.blender.org
Thu Apr 8 17:44:39 CEST 2021


Commit: 2e3b0e8a99eead1b3e8f731e7a7eb67761ec566a
Author: Hans Goudey
Date:   Thu Apr 8 10:44:33 2021 -0500
Branches: master
https://developer.blender.org/rB2e3b0e8a99eead1b3e8f731e7a7eb67761ec566a

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.

===================================================================

M	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, &region->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;



More information about the Bf-blender-cvs mailing list