Skip to content

Commit ba17bb1

Browse files
atrosinenkoadeas31
authored andcommitted
Print a warning when no platforms are specified when generating an FMU
... and also select the default choice when no such setting exists at all in omedit.ini.
1 parent b1cb26e commit ba17bb1

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

OMEdit/OMEditGUI/MainWindow.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,11 +870,22 @@ void MainWindow::exportModelFMU(LibraryTreeItem *pLibraryTreeItem)
870870
QString type = OptionsDialog::instance()->getFMIPage()->getFMIExportType();
871871
QString FMUName = OptionsDialog::instance()->getFMIPage()->getFMUNameTextBox()->text();
872872
QSettings *pSettings = Utilities::getApplicationSettings();
873-
QList<QString> platforms = pSettings->value("FMIExport/Platforms").toStringList();
873+
QList<QString> platforms;
874+
if (!pSettings->contains("FMIExport/Platforms")) {
875+
QComboBox *pLinkingComboBox = OptionsDialog::instance()->getFMIPage()->getLinkingComboBox();
876+
platforms.append(pLinkingComboBox->itemData(pLinkingComboBox->currentIndex()).toString());
877+
} else {
878+
platforms = pSettings->value("FMIExport/Platforms").toStringList();
879+
}
874880
int index = platforms.indexOf("none");
875881
if (index > -1) {
876882
platforms.removeAt(index);
877883
}
884+
if (platforms.empty()) {
885+
MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0,
886+
GUIMessages::getMessage(GUIMessages::FMU_EMPTY_PLATFORMS).arg(Helper::toolsOptionsPath),
887+
Helper::scriptingKind, Helper::warningLevel));
888+
}
878889
QString fmuFileName = mpOMCProxy->buildModelFMU(pLibraryTreeItem->getNameStructure(), version, type, FMUName, platforms);
879890
if (!fmuFileName.isEmpty()) {
880891
MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0,

OMEdit/OMEditGUI/Util/Helper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,8 @@ QString GUIMessages::getMessage(int type)
760760
return tr("A component with the name <b>%1</b> already exists. The name is changed from <b>%1</b> to <b>%2</b>.<br /><br />This is probably wrong because the component is declared as <b>inner</b>.");
761761
case FMU_GENERATED:
762762
return tr("The FMU is generated at <b>%1</b>.");
763+
case FMU_EMPTY_PLATFORMS:
764+
return tr("A source-only FMU will be generated because an empty list of platforms is selected. If this is not intended, check settings in <b>%1->FMI->Platforms</b>.");
763765
case XML_GENERATED:
764766
return tr("The XML is generated at <b>%1</b>.");
765767
case FIGARO_GENERATED:

OMEdit/OMEditGUI/Util/Helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ class GUIMessages : public QObject
443443
MAKE_REPLACEABLE_IF_PARTIAL,
444444
INNER_MODEL_NAME_CHANGED,
445445
FMU_GENERATED,
446+
FMU_EMPTY_PLATFORMS,
446447
XML_GENERATED,
447448
FIGARO_GENERATED,
448449
ENCRYPTED_PACKAGE_GENERATED,

0 commit comments

Comments
 (0)