Skip to content

Commit

Permalink
Fixed opening of files passed as command line arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Jun 24, 2015
1 parent c487dc4 commit 0c261a0
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions OMEdit/OMEditGUI/main.cpp
Expand Up @@ -220,10 +220,8 @@ int main(int argc, char *argv[])
#endif // #ifdef WIN32
#endif // #ifdef QT_NO_DEBUG
// if user asks for --help
for(int i = 1; i < argc; i++)
{
if (strcmp(argv[i], "--help") == 0)
{
for(int i = 1; i < argc; i++) {
if (strcmp(argv[i], "--help") == 0) {
printOMEditUsage();
return 0;
}
Expand Down Expand Up @@ -283,14 +281,9 @@ int main(int argc, char *argv[])
Helper::initHelperVariables();
/* Force C-style doubles */
setlocale(LC_NUMERIC, "C");
// MainWindow Initialization
MainWindow mainwindow(&splashScreen);
if (mainwindow.getExitApplicationStatus()) { // if there is some issue in running the application.
a.quit();
exit(1);
}
// if user has requested to open the file by passing it in argument then,
bool OMCLogger = false;
QStringList fileNames;
if (a.arguments().size() > 1) {
for (int i = 1; i < a.arguments().size(); i++) {
if (strncmp(a.arguments().at(i).toStdString().c_str(), "--OMCLogger=",12) == 0) {
Expand All @@ -310,11 +303,21 @@ int main(int argc, char *argv[])
fileName.prepend(QString(QDir::currentPath()).append("/"));
}
fileName = fileName.replace("\\", "/");
mainwindow.getLibraryTreeWidget()->openFile(fileName);
fileNames << fileName;
}
}
}
}
// MainWindow Initialization
MainWindow mainwindow(&splashScreen);
if (mainwindow.getExitApplicationStatus()) { // if there is some issue in running the application.
a.quit();
exit(1);
}
// open the files passed as command line arguments
foreach (QString fileName, fileNames) {
mainwindow.getLibraryTreeWidget()->openFile(fileName);
}
// hide OMCLogger send custom expression feature if OMCLogger is false
mainwindow.getOMCProxy()->enableCustomExpression(OMCLogger);
// finally show the main window
Expand Down

0 comments on commit 0c261a0

Please sign in to comment.