Skip to content

Commit

Permalink
UI: Do not generate "already active" logs
Browse files Browse the repository at this point in the history
When an user launches a multiple instance of obs and don't use the -m
flag, wait until the confirmation to launch to create a new log file.
This avoids a short log with no information when using the Help ->
Update Last Log.

Closes obsproject#1164
  • Loading branch information
admshao authored and jp9000 committed Apr 17, 2018
1 parent 30d967e commit 7fc6ea6
Showing 1 changed file with 32 additions and 19 deletions.
51 changes: 32 additions & 19 deletions UI/obs-app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1366,33 +1366,32 @@ static int run_program(fstream &logFile, int argc, char *argv[])

OBSApp program(argc, argv, profilerNameStore.get());
try {
program.AppInit();

OBSTranslator translator;
bool created_log = false;

create_log_file(logFile);
program.AppInit();
delete_oldest_file(false, "obs-studio/profiler_data");

OBSTranslator translator;
program.installTranslator(&translator);

#ifdef _WIN32
/* --------------------------------------- */
/* check and warn if already running */

bool cancel_launch = false;
bool already_running = false;
RunOnceMutex rom = GetRunOnceMutex(already_running);

if (already_running && !multi) {
blog(LOG_WARNING, "\n================================");
blog(LOG_WARNING, "Warning: OBS is already running!");
blog(LOG_WARNING, "================================\n");
if (!already_running) {
goto run;
}

if (!multi) {
QMessageBox::StandardButtons buttons(
QMessageBox::Yes | QMessageBox::Cancel);
QMessageBox mb(QMessageBox::Question,
QTStr("AlreadyRunning.Title"),
QTStr("AlreadyRunning.Text"),
buttons,
QTStr("AlreadyRunning.Text"), buttons,
nullptr);
mb.setButtonText(QMessageBox::Yes,
QTStr("AlreadyRunning.LaunchAnyway"));
Expand All @@ -1401,23 +1400,37 @@ static int run_program(fstream &logFile, int argc, char *argv[])

QMessageBox::StandardButton button;
button = (QMessageBox::StandardButton)mb.exec();
if (button == QMessageBox::Cancel) {
blog(LOG_INFO, "User shut down the program "
"because OBS was already "
"running");
return 0;
}
cancel_launch = button == QMessageBox::Cancel;
}

blog(LOG_WARNING, "User is now running a secondary "
"instance of OBS!");
if (cancel_launch)
return 0;

if (!created_log) {
create_log_file(logFile);
created_log = true;
}

} else if (already_running && multi) {
if (multi) {
blog(LOG_INFO, "User enabled --multi flag and is now "
"running multiple instances of OBS.");
} else {
blog(LOG_WARNING, "================================");
blog(LOG_WARNING, "Warning: OBS is already running!");
blog(LOG_WARNING, "================================");
blog(LOG_WARNING, "User is now running multiple "
"instances of OBS!");
}

/* --------------------------------------- */
run:
#endif

if (!created_log) {
create_log_file(logFile);
created_log = true;
}

if (argc > 1) {
stringstream stor;
stor << argv[1];
Expand Down

0 comments on commit 7fc6ea6

Please sign in to comment.