File tree Expand file tree Collapse file tree 5 files changed +18
-2
lines changed
Expand file tree Collapse file tree 5 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,13 @@ QString Helper::OpenModelicaHome = getenv("OPENMODELICAHOME");
4040QString Helper::omcServerName = " OMEditor" ;
4141QString Helper::omFileTypes = " *.mo" ;
4242QString 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
4350int Helper::viewWidth = 2000 ;
4451int Helper::viewHeight = 2000 ;
4552qreal Helper::globalIconXScale = 0.15 ;
Original file line number Diff line number Diff 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;
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ PlotWidget::PlotWidget(MainWindow *pParent)
6666
6767void 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;
Original file line number Diff line number Diff 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 '" +
You can’t perform that action at this time.
0 commit comments