From dc5dfd1eb4b686cc815bd27530095960caa4eab2 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 25 Sep 2018 16:30:04 +0300 Subject: [PATCH] Avoid unlimited cycling on nodes sorting --- src/ModuleBase/ModuleBase_ITreeNode.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ModuleBase/ModuleBase_ITreeNode.h b/src/ModuleBase/ModuleBase_ITreeNode.h index 77d1d2a46..c188dd97e 100644 --- a/src/ModuleBase/ModuleBase_ITreeNode.h +++ b/src/ModuleBase/ModuleBase_ITreeNode.h @@ -183,7 +183,10 @@ protected: ModuleBase_ITreeNode* aNode = 0; ObjectPtr aObject; int aIdx; - while (i < myChildren.size()) { + int aCount = 0; + int aSize = myChildren.size(); + while (i < aSize) { + aCount++; aNode = myChildren.at(i); aObject = aNode->object(); if (aObject.get()) { @@ -196,6 +199,9 @@ protected: } } i++; + // To avoid unlimited cycling + if (aCount > aSize * aSize) + break; } } } -- 2.39.2