correct re-launch implementation for windows

This commit is contained in:
Axel Kohlmeyer
2023-08-15 23:13:31 -04:00
parent 65cd6a3f2a
commit 653f0c4d8a

View File

@ -48,8 +48,8 @@
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#endif #endif
#include <windows.h> #include <process.h>
#define execv(exe, args) _execv(exe, args) #define execl(exe, arg0, arg1) _execl(exe, arg0, arg1)
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -158,8 +158,9 @@ void Preferences::accept()
"LAMMPS-GUI must be relaunched."), "LAMMPS-GUI must be relaunched."),
QMessageBox::Ok); QMessageBox::Ok);
msg.exec(); msg.exec();
execv(QCoreApplication::applicationFilePath().toStdString().c_str(), nullptr); const char *path = QCoreApplication::applicationFilePath().toStdString().c_str();
fprintf(stderr, "after relaunch\n"); const char *arg0 = QCoreApplication::arguments().at(0).toStdString().c_str();
execl(path, arg0, nullptr);
} }
QDialog::accept(); QDialog::accept();
} }