Windows: limit to single-instance only
This may fix corrupt config files, which may happen when multiple instances write the same file.
This commit is contained in:
parent
11932af65e
commit
4ac7df699d
@ -70,6 +70,7 @@
|
||||
#include "pbd/i18n.h"
|
||||
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
#include <windows.h> // CreateMutex
|
||||
#include <fcntl.h> // Needed for '_fmode'
|
||||
#include <shellapi.h> // console
|
||||
#endif
|
||||
@ -337,6 +338,17 @@ int main (int argc, char *argv[])
|
||||
<< endl;
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
CreateMutexA (0, 1, string_compose ("%1%2", PROGRAM_NAME, PROGRAM_VERSION).c_str ());
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS) {
|
||||
Gtk::Main main (argc, argv);
|
||||
Gtk::MessageDialog msg (string_compose (_("%1 is already running."), PROGRAM_NAME),
|
||||
false, Gtk::MESSAGE_ERROR , Gtk::BUTTONS_OK, true);
|
||||
msg.run ();
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DRMINGW
|
||||
/* prevent missing libs popups */
|
||||
UINT prev_error_mode = SetErrorMode (SEM_FAILCRITICALERRORS);
|
||||
|
Loading…
Reference in New Issue
Block a user