Skip to content

Commit

Permalink
Skip the call to diffModelicaFileListings if before and after strings…
Browse files Browse the repository at this point in the history
… are same
  • Loading branch information
adeas31 committed Jun 25, 2019
1 parent 3d25372 commit d5ff08e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
1 change: 0 additions & 1 deletion OMEdit/OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -479,7 +479,6 @@ void GraphicsView::addComponentToClass(Component *pComponent)
newUsesAnnotation.append(QString("%1(version=\"%2\")").arg(packageName).arg(pPackageLibraryTreeItem->mClassInformation.version));
QString usesAnnotationString = QString("annotate=$annotation(uses(%1))").arg(newUsesAnnotation.join(","));
pMainWindow->getOMCProxy()->addClassAnnotation(pTopLevelLibraryTreeItem->getNameStructure(), usesAnnotationString);
pLibraryTreeModel->updateLibraryTreeItemClassText(pTopLevelLibraryTreeItem);
}
}
} else if (mpModelWidget->getLibraryTreeItem()->getLibraryType()== LibraryTreeItem::CompositeModel) {
Expand Down
26 changes: 12 additions & 14 deletions OMEdit/OMEdit/OMEditGUI/OMC/OMCProxy.cpp
Expand Up @@ -1697,32 +1697,30 @@ QString OMCProxy::listFile(QString className, bool nestedClasses)
*/
QString OMCProxy::diffModelicaFileListings(QString before, QString after)
{
QString escapedBefore = StringHandler::escapeString(before);
QString escapedAfter = StringHandler::escapeString(after);
QString result;
QString result = "";
// check if both strings are same
// only use the diffModelicaFileListings when preserve text indentation settings is true
if (OptionsDialog::instance()->getModelicaEditorPage()->getPreserveTextIndentationCheckBox()->isChecked()) {
if (before.compare(after) != 0 && OptionsDialog::instance()->getModelicaEditorPage()->getPreserveTextIndentationCheckBox()->isChecked()) {
QString escapedBefore = StringHandler::escapeString(before);
QString escapedAfter = StringHandler::escapeString(after);
sendCommand("diffModelicaFileListings(\"" + escapedBefore + "\", \"" + escapedAfter + "\", OpenModelica.Scripting.DiffFormat.plain)");
result = StringHandler::unparse(getResult());
/* ticket:5413 Don't show the error of diffModelicaFileListings
* Instead show the following warning. The developers can read the actual error message from the log file.
*/
if ((getMessagesStringInternal() > 0) || (result.isEmpty())) {
QString msg = tr("Could not preserve the formatting of the original model when duplicating it. "
"The duplicate model was created with internal pretty-printing algorithm.");
QString msg = tr("Could not preserve the formatting of the model instead internal pretty-printing algorithm is used.");
MessageItem messageItem(MessageItem::Modelica, msg, Helper::scriptingKind, Helper::warningLevel);
MessagesWidget::instance()->addGUIMessage(messageItem);
}
if (result.isEmpty()) {
result = after; // use omc pretty-printing since diffModelicaFileListings() failed.
if (MainWindow::instance()->isDebug()) {
mpOMCDiffBeforeTextBox->setPlainText(before);
mpOMCDiffAfterTextBox->setPlainText(after);
mpOMCDiffMergedTextBox->setPlainText(result);
}
} else {
result = after;
}
if (MainWindow::instance()->isDebug()) {
mpOMCDiffBeforeTextBox->setPlainText(before);
mpOMCDiffAfterTextBox->setPlainText(after);
mpOMCDiffMergedTextBox->setPlainText(result);
if (result.isEmpty()) {
result = after; // use omc pretty-printing since diffModelicaFileListings() failed OR Preserve Text Indentation is not enabled.
}
return result;
}
Expand Down

0 comments on commit d5ff08e

Please sign in to comment.