From 5d1022e813931bd755650424f15864ffa5b65269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sj=C3=B6lund?= Date: Thu, 7 May 2020 16:16:50 +0200 Subject: [PATCH] Do not hardcode OPENMODELICAHOME in OMEdit This resolves ticket:5640. --- OMCompiler/Compiler/runtime/settingsimpl.h | 6 ++++++ OMEdit/OMEditGUI/OMEditGUI.unix.config.pri.in | 2 +- OMEdit/OMEditGUI/OMEditGUI.win.config.pri | 2 +- OMEdit/OMEditLIB/OMEditApplication.cpp | 8 +++----- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/OMCompiler/Compiler/runtime/settingsimpl.h b/OMCompiler/Compiler/runtime/settingsimpl.h index b768e3eaf05..86f63e3336c 100644 --- a/OMCompiler/Compiler/runtime/settingsimpl.h +++ b/OMCompiler/Compiler/runtime/settingsimpl.h @@ -30,6 +30,12 @@ #ifndef SETTINGSIMPL__H_ #define SETTINGSIMPL__H_ +#ifdef __cplusplus +extern "C" { +#endif extern const char* SettingsImpl__getInstallationDirectoryPath(); extern const char* SettingsImpl__getTempDirectoryPath(); +#ifdef __cplusplus +} +#endif #endif diff --git a/OMEdit/OMEditGUI/OMEditGUI.unix.config.pri.in b/OMEdit/OMEditGUI/OMEditGUI.unix.config.pri.in index 2772cd7f3d5..c518606fa68 100644 --- a/OMEdit/OMEditGUI/OMEditGUI.unix.config.pri.in +++ b/OMEdit/OMEditGUI/OMEditGUI.unix.config.pri.in @@ -7,7 +7,7 @@ QMAKE_LINK = @CXX@ OPENMODELICAHOME = @OPENMODELICAHOME@ host_short = @host_short@ -LIBS += -L@OPENMODELICAHOME@/lib/$$host_short/omc -lOMPlot -lomqwt -lfmilib_shared -L$$OMEDIT_ROOT/OMEditLIB/Debugger/Parser -lGDBMIParser -lomantlr3 @RPATH_QMAKE@ -lOpenModelicaCompiler -lOpenModelicaRuntimeC -lomcgc -L@OMBUILDDIR@/lib/$$host_short/omc @LIBOSG@ -lomopcua -L@OMBUILDDIR@/lib -lOMSimulator -lqjson @LIB_BOOST_REGEX@ +LIBS += -L@OPENMODELICAHOME@/lib/$$host_short/omc -lOMPlot -lomqwt -lfmilib_shared -L$$OMEDIT_ROOT/OMEditLIB/Debugger/Parser -lGDBMIParser -lomantlr3 @RPATH_QMAKE@ -lOpenModelicaCompiler -lOpenModelicaRuntimeC -lomcruntime -lomcgc -L@OMBUILDDIR@/lib/$$host_short/omc @LIBOSG@ -lomopcua -L@OMBUILDDIR@/lib -lOMSimulator -lqjson @LIB_BOOST_REGEX@ QMAKE_CXXFLAGS_RELEASE -= -O1 QMAKE_CXXFLAGS_RELEASE -= -O2 diff --git a/OMEdit/OMEditGUI/OMEditGUI.win.config.pri b/OMEdit/OMEditGUI/OMEditGUI.win.config.pri index e6d8ffc09e5..f2e0caebb4d 100644 --- a/OMEdit/OMEditGUI/OMEditGUI.win.config.pri +++ b/OMEdit/OMEditGUI/OMEditGUI.win.config.pri @@ -62,6 +62,6 @@ CONFIG(release, debug|release) { # release } LIBS += -L$$OMEDIT_ROOT/OMEditLIB/Debugger/Parser -lGDBMIParser \ -L$$(OMBUILDDIR)/lib/omc -lomantlr3 -lOMPlot -lomqwt -lomopcua \ - -lOpenModelicaCompiler -lOpenModelicaRuntimeC -lfmilib -lModelicaExternalC -lomcgc -lpthread -lshlwapi \ + -lOpenModelicaCompiler -lomcruntime -lOpenModelicaRuntimeC -lfmilib -lModelicaExternalC -lomcgc -lpthread -lshlwapi \ -lws2_32 \ -L$$(OMBUILDDIR)/bin -lOMSimulator -lqjson diff --git a/OMEdit/OMEditLIB/OMEditApplication.cpp b/OMEdit/OMEditLIB/OMEditApplication.cpp index 0e4ccff1f23..cbbeb33a926 100644 --- a/OMEdit/OMEditLIB/OMEditApplication.cpp +++ b/OMEdit/OMEditLIB/OMEditApplication.cpp @@ -40,6 +40,8 @@ #include #include +#include "../../OMCompiler/Compiler/runtime/settingsimpl.h" + /*! * \class OMEditApplication * \brief It is a subclass for QApplication so that we can handle QFileOpenEvent sent by OSX at startup. @@ -65,17 +67,13 @@ OMEditApplication::OMEditApplication(int &argc, char **argv, threadData_t* threa setAttribute(Qt::AA_DontShowIconsInMenus, false); // Localization //*a.severin/ add localization - const char *omhome = getenv("OPENMODELICAHOME"); -#ifdef WIN32 + const char *omhome = SettingsImpl__getInstallationDirectoryPath(); if (!omhome) { QMessageBox::critical(0, QString(Helper::applicationName).append(" - ").append(Helper::error), GUIMessages::getMessage(GUIMessages::OPENMODELICAHOME_NOT_FOUND), Helper::ok); quit(); exit(1); } -#else /* unix */ - omhome = omhome ? omhome : CONFIG_DEFAULT_OPENMODELICAHOME; -#endif QSettings *pSettings = Utilities::getApplicationSettings(); QLocale settingsLocale = QLocale(pSettings->value("language").toString()); settingsLocale = settingsLocale.name() == "C" ? pSettings->value("language").toLocale() : settingsLocale;