Skip to content

Commit

Permalink
Some fixes from the static analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Dec 8, 2016
1 parent 21c9c6d commit f86d92d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
16 changes: 11 additions & 5 deletions OMEdit/OMEditGUI/Component/Component.cpp
Expand Up @@ -1261,10 +1261,13 @@ void Component::drawInheritedComponentsAndShapes()
{
if (!mpLibraryTreeItem) { // if built in type e.g Real, Boolean etc.
if (mComponentType == Component::Root) {
assert(mpDefaultComponentRectangle);
assert(mpDefaultComponentText);
mpDefaultComponentRectangle->setVisible(true);
mpDefaultComponentText->setVisible(true);
}
} else if (mpLibraryTreeItem->isNonExisting()) { // if class is non existing
assert(mpNonExistingComponentLine);
mpNonExistingComponentLine->setVisible(true);
} else {
createClassInheritedComponents();
Expand All @@ -1280,17 +1283,20 @@ void Component::showNonExistingOrDefaultComponentIfNeeded()
{
mpNonExistingComponentLine->setVisible(false);
if (mComponentType == Component::Root) {
assert(mpDefaultComponentRectangle);
assert(mpDefaultComponentText);
mpDefaultComponentRectangle->setVisible(false);
mpDefaultComponentText->setVisible(false);
}
if (!hasShapeAnnotation(this)) {
if (hasNonExistingClass()) {
assert(mpNonExistingComponentLine);
mpNonExistingComponentLine->setVisible(true);
} else {
if (mComponentType == Component::Root) {
mpDefaultComponentRectangle->setVisible(true);
mpDefaultComponentText->setVisible(true);
}
} else if (mComponentType == Component::Root) {
assert(mpDefaultComponentRectangle);
assert(mpDefaultComponentText);
mpDefaultComponentRectangle->setVisible(true);
mpDefaultComponentText->setVisible(true);
}
}
}
Expand Down
20 changes: 11 additions & 9 deletions OMEdit/OMEditGUI/Editors/ModelicaEditor.cpp
Expand Up @@ -541,21 +541,23 @@ void ModelicaHighlighter::highlightMultiLine(const QString &text)
// if no single line comment, no multi line comment and no quotes then check for annotation end
if (blockState < 1 || blockState > 3) {
if (text[index] == ';') {
if (index == text.length() - 1) { // if we have some text after closing the annotation then we don't want to fold it.
if (annotationIndex < 0) { // if we have one line annotation, we don't want to fold it.
pTextBlockUserData->setFoldingIndent(1);
if (pTextBlockUserData) {
if (index == text.length() - 1) { // if we have some text after closing the annotation then we don't want to fold it.
if (annotationIndex < 0) { // if we have one line annotation, we don't want to fold it.
pTextBlockUserData->setFoldingIndent(1);
}
pTextBlockUserData->setFoldingEndIncluded(true);
} else {
pTextBlockUserData->setFoldingIndent(0);
}
pTextBlockUserData->setFoldingEndIncluded(true);
} else {
pTextBlockUserData->setFoldingIndent(0);
}
foldingState = false;
} else if (annotationIndex < 0) { // if we have one line annotation, we don't want to fold it.
} else if (pTextBlockUserData && annotationIndex < 0) { // if we have one line annotation, we don't want to fold it.
pTextBlockUserData->setFoldingIndent(1);
}
} else if (annotationIndex < 0) { // if we have one line annotation, we don't want to fold it.
} else if (pTextBlockUserData && annotationIndex < 0) { // if we have one line annotation, we don't want to fold it.
pTextBlockUserData->setFoldingIndent(1);
} else if (startIndex < annotationIndex) { // if we have annotation word before quote or comment block is starting then fold.
} else if (pTextBlockUserData && startIndex < annotationIndex) { // if we have annotation word before quote or comment block is starting then fold.
pTextBlockUserData->setFoldingIndent(1);
}
} else {
Expand Down
16 changes: 9 additions & 7 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -4194,14 +4194,16 @@ bool LibraryWidget::saveMetaModelLibraryTreeItem(LibraryTreeItem *pLibraryTreeIt
}
QFile::copy(modelFileInfo.absoluteFilePath(), newModelFilePath);
// copy the geomtry file to the created directory
QFileInfo geometryFileInfo(pComponent->getComponentInfo()->getGeometryFile());
QString newGeometryFilePath = directoryPath + "/" + geometryFileInfo.fileName();
if (geometryFileInfo.absoluteFilePath().compare(newGeometryFilePath) != 0) {
// first try to remove the file because QFile::copy will not override the file.
QFile::remove(newGeometryFilePath);
if (pComponent) {
QFileInfo geometryFileInfo(pComponent->getComponentInfo()->getGeometryFile());
QString newGeometryFilePath = directoryPath + "/" + geometryFileInfo.fileName();
if (geometryFileInfo.absoluteFilePath().compare(newGeometryFilePath) != 0) {
// first try to remove the file because QFile::copy will not override the file.
QFile::remove(newGeometryFilePath);
}
QFile::copy(geometryFileInfo.absoluteFilePath(), newGeometryFilePath);
pComponent->getComponentInfo()->setGeometryFile(newGeometryFilePath);
}
QFile::copy(geometryFileInfo.absoluteFilePath(), newGeometryFilePath);
pComponent->getComponentInfo()->setGeometryFile(newGeometryFilePath);
}
} else {
return false;
Expand Down

0 comments on commit f86d92d

Please sign in to comment.