Skip to content

Commit

Permalink
Prevent adding same DCP server twice in same model
Browse files Browse the repository at this point in the history
  • Loading branch information
robbr48 committed Apr 14, 2021
1 parent 1307b50 commit 8552ba0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions HopsanGUI/GraphicsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ void GraphicsView::contextMenuEvent ( QContextMenuEvent * event )
QFileInfo dcpFileInfo(dcpPath);
gpConfig->setStringSetting(CFG_DCPDIR, dcpFileInfo.absolutePath());

//Check that DCP server is not already added to model
for(const auto &comp : mpParentModelWidget->getTopLevelSystemContainer()->getModelObjects()) {
if(comp->getParameterValue("dcpFile") == dcpFileInfo.absoluteFilePath()) {
gpMessageHandler->addErrorMessage("Specified DCP server already exists in model. Only one instance is allowed.");
return;
}
}

hopsan::HString name, variables, valueRefs;
getDataFromProtocolFile(dcpFileInfo.filePath().toStdString().c_str(), name, variables, valueRefs);

Expand Down

0 comments on commit 8552ba0

Please sign in to comment.