From 527bcb246bb1d82695417e9b68a728c2f9185f79 Mon Sep 17 00:00:00 2001 From: Andreas Falkenhahn Date: Fri, 11 Jun 2021 00:16:12 +0200 Subject: [PATCH] Fix item position in sorted generic wxDataViewCtrl Compare the item whose value has changed with both the previous and the next items, if any. Closes #19194. --- src/generic/datavgen.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 449f355668..a51b48190b 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -1968,15 +1968,15 @@ wxDataViewTreeNode::PutChildInSortOrder(wxDataViewMainWindow* window, // Check if we actually need to move the node. bool locationChanged = false; - if ( oldLocation == 0 ) + // Compare with next node + if ( oldLocation != hi - 1) { - // Compare with the next item (as we return early in the case of only a - // single child, we know that there is one) to check if the item is now - // out of order. - if ( !cmp(childNode, nodes[1]) ) + if ( !cmp(childNode, nodes[oldLocation + 1]) ) locationChanged = true; } - else // Compare with the previous item. + + // Compare with previous node + if ( !locationChanged && oldLocation > 0 ) { if ( !cmp(nodes[oldLocation - 1], childNode) ) locationChanged = true;