From 3baccdc56fe8ee28805f2424687f25d2ff16f6b0 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 7 Sep 2018 18:30:17 +0300 Subject: [PATCH] Issue #2630: Prevent cycling of children nodes sorting. --- src/ModuleBase/ModuleBase_ITreeNode.h | 32 ++++++++++++++------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/ModuleBase/ModuleBase_ITreeNode.h b/src/ModuleBase/ModuleBase_ITreeNode.h index fcd6c7bd4..77d1d2a46 100644 --- a/src/ModuleBase/ModuleBase_ITreeNode.h +++ b/src/ModuleBase/ModuleBase_ITreeNode.h @@ -178,23 +178,25 @@ protected: } void sortChildren() { - int i = 0; - ModuleBase_ITreeNode* aNode = 0; - ObjectPtr aObject; - int aIdx; - while (i < myChildren.size()) { - aNode = myChildren.at(i); - aObject = aNode->object(); - if (aObject.get()) { - aIdx = aObject->document()->index(aObject, true); - if (aIdx != i) { - myChildren.removeAll(aNode); - myChildren.insert(aIdx, aNode); - i = 0; - continue; + if (myChildren.size() > 1) { + int i = 0; + ModuleBase_ITreeNode* aNode = 0; + ObjectPtr aObject; + int aIdx; + while (i < myChildren.size()) { + aNode = myChildren.at(i); + aObject = aNode->object(); + if (aObject.get()) { + aIdx = aObject->document()->index(aObject, true); + if (aIdx != i) { + myChildren.removeAll(aNode); + myChildren.insert(aIdx, aNode); + i = 0; + continue; + } } + i++; } - i++; } } -- 2.39.2