Browse Source

UI: Show output's last error in failure dialog

Logs the last output error if given.
Matthew Orlando 6 years ago
parent
commit
54e7267ad9
3 changed files with 22 additions and 13 deletions
  1. 16 10
      UI/window-basic-main-outputs.cpp
  2. 1 0
      UI/window-basic-main-outputs.hpp
  3. 5 3
      UI/window-basic-main.cpp

+ 16 - 10
UI/window-basic-main-outputs.cpp

@@ -771,12 +771,15 @@ bool SimpleOutput::StartStreaming(obs_service_t *service)
 	}
 
 	const char *error = obs_output_get_last_error(streamOutput);
-	bool has_last_error = error && *error;
+	bool hasLastError = error && *error;
+	if (hasLastError)
+		lastError = error;
+	else
+		lastError = string();
 
-	blog(LOG_WARNING, "Stream output type '%s' failed to start!%s%s",
-			type,
-			has_last_error ? "  Last Error: " : "",
-			has_last_error ? error : "");
+	blog(LOG_WARNING, "Stream output type '%s' failed to start!%s%s", type,
+			hasLastError ? "  Last Error: " : "",
+			hasLastError ? error : "");
 	return false;
 }
 
@@ -1561,12 +1564,15 @@ bool AdvancedOutput::StartStreaming(obs_service_t *service)
 	}
 
 	const char *error = obs_output_get_last_error(streamOutput);
-	bool has_last_error = error && *error;
+	bool hasLastError = error && *error;
+	if (hasLastError)
+		lastError = error;
+	else
+		lastError = string();
 
-	blog(LOG_WARNING, "Stream output type '%s' failed to start!%s%s",
-			type,
-			has_last_error ? "  Last Error: " : "",
-			has_last_error ? error : "");
+	blog(LOG_WARNING, "Stream output type '%s' failed to start!%s%s", type,
+			hasLastError ? "  Last Error: " : "",
+			hasLastError ? error : "");
 	return false;
 }
 

+ 1 - 0
UI/window-basic-main-outputs.hpp

@@ -15,6 +15,7 @@ struct BasicOutputHandler {
 	OBSBasic               *main;
 
 	std::string            outputType;
+	std::string            lastError;
 
 	OBSSignal              startRecording;
 	OBSSignal              stopRecording;

+ 5 - 3
UI/window-basic-main.cpp

@@ -4762,6 +4762,9 @@ void OBSBasic::StartStreaming()
 	}
 
 	if (!outputHandler->StartStreaming(service)) {
+		QString message = !outputHandler->lastError.empty()
+			? QTStr(outputHandler->lastError.c_str())
+			: QTStr("Output.StartFailedGeneric");
 		ui->streamButton->setText(QTStr("Basic.Main.StartStreaming"));
 		ui->streamButton->setEnabled(true);
 		ui->streamButton->setChecked(false);
@@ -4771,9 +4774,8 @@ void OBSBasic::StartStreaming()
 			sysTrayStream->setEnabled(true);
 		}
 
-		QMessageBox::critical(this,
-				QTStr("Output.StartStreamFailed"),
-				QTStr("Output.StartFailedGeneric"));
+		QMessageBox::critical(this, QTStr("Output.StartStreamFailed"),
+				message);
 		return;
 	}