mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-07 23:20:03 +02:00
Run only one instance of Windows Interface at a time
OSX automatically does this.
This commit is contained in:
parent
6a4577b6a5
commit
1fa50fa54d
1 changed files with 16 additions and 0 deletions
|
@ -18,6 +18,17 @@
|
|||
#include "Application.h"
|
||||
|
||||
int main(int argc, const char * argv[]) {
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
// Run only one instance of Interface at a time.
|
||||
HANDLE mutex = CreateMutex(NULL, FALSE, "High Fidelity Interface");
|
||||
DWORD result = GetLastError();
|
||||
if (result == ERROR_ALREADY_EXISTS || result == ERROR_ACCESS_DENIED) {
|
||||
// Interface is already running.
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
QElapsedTimer startupTime;
|
||||
startupTime.start();
|
||||
|
||||
|
@ -44,6 +55,11 @@ int main(int argc, const char * argv[]) {
|
|||
qDebug( "Created QT Application.");
|
||||
exitCode = app.exec();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
ReleaseMutex(mutex);
|
||||
#endif
|
||||
|
||||
qDebug("Normal exit.");
|
||||
return exitCode;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue