Skip to content

Commit

Permalink
Do not add the items to the scene if there are no annotations (#7029)
Browse files Browse the repository at this point in the history
Fixes ticket #6271
  • Loading branch information
adeas31 committed Dec 9, 2020
1 parent 0e1ad5c commit 55290b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
12 changes: 8 additions & 4 deletions OMEdit/OMEditLIB/Modeling/Commands.cpp
Expand Up @@ -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();
Expand Down
7 changes: 4 additions & 3 deletions OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 55290b5

Please sign in to comment.