From 570e9d2bb33d8518f5da4e4aee6499614fca69ab Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Apr 2025 20:42:27 +1000 Subject: [PATCH] Cleanup: correct logic for qsort callback Adding the additional check is more of a "technical" correction, for the callback to return 0 the sort implementation would have to compare an element in the array with itself. Co-authored-by: Zheng-Ze Ref !137723 --- source/blender/editors/object/object_vgroup.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/object/object_vgroup.cc b/source/blender/editors/object/object_vgroup.cc index c3bc18eb459..235a1b1ea61 100644 --- a/source/blender/editors/object/object_vgroup.cc +++ b/source/blender/editors/object/object_vgroup.cc @@ -1849,10 +1849,15 @@ static int inv_cmp_mdef_vert_weights(const void *a1, const void *a2) if (dw1->weight > dw2->weight) { return -1; } + + /* Compare address for stable sort algorithm. */ if (&dw1 < &dw2) { - return 1; /* compare address for stable sort algorithm */ + return 1; } - return -1; + if (&dw1 > &dw2) { + return -1; + } + return 0; } /* Used for limiting the number of influencing bones per vertex when exporting