Skip to content

Commit 6339912

Browse files
committed
Fix for naming index bug enigma-dev#223
1 parent 31dbcb7 commit 6339912

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

MainWindow.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,13 @@ void MainWindow::CreateResource(TypeCase typeCase) {
564564
refl->MutableMessage(&child, field);
565565

566566
// find a unique name for the new resource
567-
child.set_name(resourceMap->CreateResourceName(&child).toStdString());
567+
QString resourceName = resourceMap->CreateResourceName(&child);
568+
child.set_name(resourceName.toStdString());
569+
570+
// add new resource with created name, helps in creating another unique name
571+
auto messageModelRef = MessageModel(ProtoModel::NonProtoParent{this}, &child);
572+
resourceMap->AddResource(typeCase, resourceName, &messageModelRef);
573+
568574
// release ownership of the new child to its parent and the tree
569575
auto index = this->treeModel->addNode(child, _ui->treeView->currentIndex());
570576
treeModel->triggerNodeEdit(index, _ui->treeView);

0 commit comments

Comments
 (0)