Skip to content

Commit 052a2a9

Browse files
committed
- Some minor OMEdit fixes
- Set a proper Unix tmp-path except when on Windows - Change to this directory at program start since instantiation may cause files to be generated in the current directory git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7006 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 7c823c0 commit 052a2a9

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

OMEdit/OMEditGUI/Helper.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ QString Helper::OpenModelicaHome = getenv("OPENMODELICAHOME");
4040
QString Helper::omcServerName = "OMEditor";
4141
QString Helper::omFileTypes = "*.mo";
4242
QString Helper::omFileOpenText = "Modelica Files (*.mo)";
43+
#ifdef WIN32
44+
QString Helper::tmpPath = QString(getenv("OPENMODELICAHOME")).append(QString("/tmp/OMEdit"));
45+
#else
46+
// Linux users don't have write access to /usr/tmp/OMEdit
47+
// Don't randomize the path as then it becomes annoying to remove all dirs
48+
QString Helper::tmpPath = QString("/tmp/OMEdit");
49+
#endif
4350
int Helper::viewWidth = 2000;
4451
int Helper::viewHeight = 2000;
4552
qreal Helper::globalIconXScale = 0.15;

OMEdit/OMEditGUI/Helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class Helper
4848
static QString omcServerName;
4949
static QString omFileTypes;
5050
static QString omFileOpenText;
51+
static QString tmpPath;
5152
static int viewWidth;
5253
static int viewHeight;
5354
static qreal globalIconXScale;

OMEdit/OMEditGUI/OMCProxy.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,15 @@ bool OMCProxy::startServer()
252252
mHasInitialized = false;
253253
return false;
254254
}
255+
QDir dir;
256+
if (!dir.exists(Helper::tmpPath)) {
257+
if (!dir.mkdir(Helper::tmpPath)) {
258+
QMessageBox::critical(mpParentMainWindow, Helper::applicationName + " - Error",
259+
QString("Failed to create temp dir ").append(Helper::tmpPath), "OK");
260+
return false;
261+
}
262+
}
263+
changeDirectory(Helper::tmpPath);
255264
return true;
256265
}
257266

OMEdit/OMEditGUI/PlotWidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ PlotWidget::PlotWidget(MainWindow *pParent)
6666

6767
void PlotWidget::readPlotVariables(QString fileName)
6868
{
69-
QFile simulationResultFile(QString(Helper::OpenModelicaHome).append("/tmp/").append(fileName));
69+
QFile simulationResultFile(Helper::tmpPath.append("/").append(fileName));
7070
simulationResultFile.open(QIODevice::ReadOnly);
7171

7272
QList<QString> plotVariablesList;

OMEdit/OMEditGUI/SimulationWidget.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ void SimulationWidget::simulate()
183183
progressBar.show();
184184
progressBar.setValue(endtime/2);
185185

186-
mpParentMainWindow->mpOMCProxy->changeDirectory(QString(Helper::OpenModelicaHome).append("\\tmp"));
187186
if (!mpParentMainWindow->mpOMCProxy->simulate(projectTab->mModelNameStructure, simualtionParameters))
188187
{
189188
mpParentMainWindow->mpMessageWidget->printGUIErrorMessage("Enable to simulate the Model '" +

0 commit comments

Comments
 (0)