UI: Simplify multi-instance check

master
gxalpha 2022-02-28 22:43:06 +01:00 committed by Jim
parent c7c52a59f9
commit 6d86b58ed7
5 changed files with 16 additions and 21 deletions

View File

@ -2099,15 +2099,10 @@ static int run_program(fstream &logFile, int argc, char *argv[])
bool cancel_launch = false;
bool already_running = false;
#if defined(_WIN32)
RunOnceMutex rom = GetRunOnceMutex(already_running);
#elif defined(__APPLE__)
CheckAppWithSameBundleID(already_running);
#elif defined(__linux__)
RunningInstanceCheck(already_running);
#elif defined(__FreeBSD__) || defined(__DragonFly__)
PIDFileCheck(already_running);
#ifdef _WIN32
RunOnceMutex rom =
#endif
CheckIfAlreadyRunning(already_running);
if (!already_running) {
goto run;

View File

@ -88,7 +88,7 @@ bool InitApplicationBundle()
#endif
}
void CheckAppWithSameBundleID(bool &already_running)
void CheckIfAlreadyRunning(bool &already_running)
{
try {
NSBundle *bundle = [NSBundle mainBundle];
@ -107,7 +107,7 @@ void CheckAppWithSameBundleID(bool &already_running)
already_running = app_count > 1;
} catch (const char *error) {
blog(LOG_ERROR, "CheckAppWithSameBundleID: %s", error);
blog(LOG_ERROR, "CheckIfAlreadyRunning: %s", error);
}
}

View File

@ -328,7 +328,7 @@ RunOnceMutex &RunOnceMutex::operator=(RunOnceMutex &&rom)
return *this;
}
RunOnceMutex GetRunOnceMutex(bool &already_running)
RunOnceMutex CheckIfAlreadyRunning(bool &already_running)
{
string name;

View File

@ -53,7 +53,7 @@ using std::vector;
using std::ostringstream;
#ifdef __linux__
void RunningInstanceCheck(bool &already_running)
void CheckIfAlreadyRunning(bool &already_running)
{
int uniq = socket(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
@ -133,7 +133,7 @@ struct RunOnce {
} RO;
const char *RunOnce::thr_name = "OBS runonce";
void PIDFileCheck(bool &already_running)
void CheckIfAlreadyRunning(bool &already_running)
{
std::string tmpfile_name =
"/tmp/obs-studio.lock." + std::to_string(geteuid());

View File

@ -39,6 +39,14 @@ void SetAlwaysOnTop(QWidget *window, bool enable);
bool SetDisplayAffinitySupported(void);
#ifdef _WIN32
class RunOnceMutex;
RunOnceMutex
#else
void
#endif
CheckIfAlreadyRunning(bool &already_running);
#ifdef _WIN32
uint32_t GetWindowsVersion();
uint32_t GetWindowsBuild();
@ -62,7 +70,6 @@ public:
RunOnceMutex &operator=(RunOnceMutex &&rom);
};
RunOnceMutex GetRunOnceMutex(bool &already_running);
QString GetMonitorName(const QString &id);
bool IsRunningOnWine();
#endif
@ -72,12 +79,5 @@ void EnableOSXVSync(bool enable);
void EnableOSXDockIcon(bool enable);
void InstallNSApplicationSubclass();
void disableColorSpaceConversion(QWidget *window);
void CheckAppWithSameBundleID(bool &already_running);
bool ProcessIsRosettaTranslated();
#endif
#ifdef __linux__
void RunningInstanceCheck(bool &already_running);
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
void PIDFileCheck(bool &already_running);
#endif