if (!aDoc.get())
return;
+ std::string aGroup = groupName();
+
// Remove extra sub-nodes
- int aIndex;
int aId = 0;
+ int nbObjs = aDoc->size(aGroup, true);
while (aId < myChildren.size()) {
ModuleBase_ITreeNode* aNode = myChildren.at(aId);
- aIndex = aDoc->index(aNode->object(), true);
- if ((aIndex == -1) || (aId != aIndex)) {
+ bool isObj = false;
+ if (aId < nbObjs) {
+ ObjectPtr aObj = aDoc->object(aGroup, aId, true);
+ if (aNode->object() == aObj)
+ isObj = true;
+ }
+ if (!isObj) {
myChildren.removeAll(aNode);
delete aNode;
} else
}
// Add new nodes
- std::string aGroup = groupName();
int aSize = aDoc->size(aGroup, true);
for (int i = 0; i < aSize; i++) {
ObjectPtr aObj = aDoc->object(aGroup, i, true);
DocumentPtr aDoc = document();
int aNb = numberOfFolders();
+ std::string aGroup = ModelAPI_Feature::group();
+
// Remove extra sub-nodes
- int aIndex;
int aId = 0;
+ int nbObjs = aDoc->size(aGroup, true);
while (aId < myChildren.size()) {
ModuleBase_ITreeNode* aNode = myChildren.at(aId);
if (aNode->object().get()) {
- aIndex = aDoc->index(aNode->object(), true);
- if ((aIndex == -1) || (aId != (aIndex + aNb))) {
+ bool isObj = false;
+ if (aId - aNb < nbObjs) {
+ ObjectPtr aObj = aDoc->object(aGroup, aId - aNb, true);
+ if (aNode->object() == aObj)
+ isObj = true;
+ }
+ if (!isObj) {
myChildren.removeAll(aNode);
delete aNode;
continue;
}
// Add new nodes
- std::string aGroup = ModelAPI_Feature::group();
int aSize = aDoc->size(aGroup, true);
FeaturePtr aFeature;
for (int i = 0; i < aSize; i++) {