diff --git a/OMEdit/OMEditLIB/Modeling/Commands.cpp b/OMEdit/OMEditLIB/Modeling/Commands.cpp index 0f0354cc090..89a55e27cf3 100644 --- a/OMEdit/OMEditLIB/Modeling/Commands.cpp +++ b/OMEdit/OMEditLIB/Modeling/Commands.cpp @@ -256,16 +256,20 @@ void AddComponentCommand::redoInternal() // if component is of connector type && containing class is Modelica type. if (mpLibraryTreeItem && mpLibraryTreeItem->isConnector() && pModelWidget->getLibraryTreeItem()->getLibraryType() == LibraryTreeItem::Modelica) { // Connector type components exists on icon view as well - mpIconGraphicsView->addItem(mpIconComponent); - mpIconGraphicsView->addItem(mpIconComponent->getOriginItem()); + if (mpIconComponent->mTransformation.isValid() && mpIconComponent->mTransformation.getVisible()) { + mpIconGraphicsView->addItem(mpIconComponent); + mpIconGraphicsView->addItem(mpIconComponent->getOriginItem()); + } mpIconGraphicsView->addElementToList(mpIconComponent); mpIconGraphicsView->deleteElementFromOutOfSceneList(mpIconComponent); mpIconComponent->emitAdded(); // hide the component if it is connector and is protected mpIconComponent->setVisible(!mpComponentInfo->getProtected()); } - mpDiagramGraphicsView->addItem(mpDiagramComponent); - mpDiagramGraphicsView->addItem(mpDiagramComponent->getOriginItem()); + if (mpDiagramComponent->mTransformation.isValid() && mpDiagramComponent->mTransformation.getVisible()) { + mpDiagramGraphicsView->addItem(mpDiagramComponent); + mpDiagramGraphicsView->addItem(mpDiagramComponent->getOriginItem()); + } mpDiagramGraphicsView->addElementToList(mpDiagramComponent); mpDiagramGraphicsView->deleteElementFromOutOfSceneList(mpDiagramComponent); mpDiagramComponent->emitAdded(); diff --git a/OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.cpp b/OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.cpp index 019c7531798..fefd1229053 100644 --- a/OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.cpp +++ b/OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.cpp @@ -4615,9 +4615,10 @@ void ModelWidget::addConnection(QStringList connectionList, QString connectionAn MainWindow *pMainWindow = MainWindow::instance(); LibraryTreeModel *pLibraryTreeModel = pMainWindow->getLibraryWidget()->getLibraryTreeModel(); QString connectionString = QString("{%1}").arg(connectionList.join(",")); - // if the connectionString only contains two items then continue the loop, + connectionAnnotationString = StringHandler::removeFirstLastCurlBrackets(connectionAnnotationString); + // if the connectionString only contains two items or if there is no connection annotation then continue the loop, // because connection is not valid then - if (connectionList.size() < 3) { + if (connectionList.size() < 3 || connectionAnnotationString.isEmpty()) { return; } // get start and end components @@ -4694,7 +4695,7 @@ void ModelWidget::addConnection(QStringList connectionList, QString connectionAn return; } // connection annotation - QStringList shapesList = StringHandler::getStrings(StringHandler::removeFirstLastCurlBrackets(connectionAnnotationString), '(', ')'); + QStringList shapesList = StringHandler::getStrings(connectionAnnotationString, '(', ')'); // Now parse the shapes available in list QString lineShape = ""; foreach (QString shape, shapesList) {