Skip to content

Commit

Permalink
Fixes #3580. Start component name could be an array.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Dec 7, 2015
1 parent 671e1ea commit ad6ae67
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -3328,17 +3328,17 @@ void ModelWidget::getModelConnections()
// get start and end components
QStringList startComponentList = connectionList.at(0).split(".");
QStringList endComponentList = connectionList.at(1).split(".");
QString errorMessage = tr("Unable to find component %1 while parsing connection %2.").arg(connectionList.at(0)).arg(connectionString);
// get start component
Component *pStartComponent = 0;
if (startComponentList.size() > 0) {
pStartComponent = mpDiagramGraphicsView->getComponentObject(startComponentList.at(0));
}
// get end component
Component *pEndComponent = 0;
if (endComponentList.size() > 0) {
pEndComponent = mpDiagramGraphicsView->getComponentObject(endComponentList.at(0));
QString startComponentName = startComponentList.at(0);
if (startComponentName.contains("[")) {
startComponentName = startComponentName.mid(0, startComponentName.indexOf("["));
}
pStartComponent = mpDiagramGraphicsView->getComponentObject(startComponentName);
}
// get start and end connectors
// get start connector
Component *pStartConnectorComponent = 0;
Component *pEndConnectorComponent = 0;
if (pStartComponent) {
Expand All @@ -3358,6 +3358,22 @@ void ModelWidget::getModelConnections()
pStartConnectorComponent = getConnectorComponent(pStartComponent, startComponentName);
}
}
// show error message if start component is not found.
if (!pStartConnectorComponent) {
pMainWindow->getMessagesWidget()->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0, errorMessage,
Helper::scriptingKind, Helper::errorLevel));
continue;
}
// get end component
Component *pEndComponent = 0;
if (endComponentList.size() > 0) {
QString endComponentName = endComponentList.at(0);
if (endComponentName.contains("[")) {
endComponentName = endComponentName.mid(0, endComponentName.indexOf("["));
}
pEndComponent = mpDiagramGraphicsView->getComponentObject(endComponentList.at(0));
}
// get the end connector
if (pEndComponent) {
// if a component type is connector then we only get one item in endComponentList
// check the endcomponentlist
Expand All @@ -3374,6 +3390,12 @@ void ModelWidget::getModelConnections()
pEndConnectorComponent = getConnectorComponent(pEndComponent, endComponentName);
}
}
// show error message if end component is not found.
if (!pEndConnectorComponent) {
pMainWindow->getMessagesWidget()->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0, errorMessage,
Helper::scriptingKind, Helper::errorLevel));
continue;
}
// get the connector annotations from OMC
QString connectionAnnotationString = pMainWindow->getOMCProxy()->getNthConnectionAnnotation(mpLibraryTreeItem->getNameStructure(), i);
QStringList shapesList = StringHandler::getStrings(StringHandler::removeFirstLastCurlBrackets(connectionAnnotationString), '(', ')');
Expand Down

0 comments on commit ad6ae67

Please sign in to comment.