Browse Source

UI: Fix potential crash when outputs change

If the service settings change and the output type changes, the previous
signals would attempt to disconnect after the output has been destroyed,
and subsequently that would cause a crash.
jp9000 8 years ago
parent
commit
960958a4ca
1 changed files with 10 additions and 0 deletions
  1. 10 0
      UI/window-basic-main-outputs.cpp

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

@@ -662,6 +662,11 @@ bool SimpleOutput::StartStreaming(obs_service_t *service)
 
 	/* XXX: this is messy and disgusting and should be refactored */
 	if (outputType != type) {
+		streamDelayStarting.Disconnect();
+		streamStopping.Disconnect();
+		startStreaming.Disconnect();
+		stopStreaming.Disconnect();
+
 		streamOutput = obs_output_create(type, "simple_stream",
 				nullptr, nullptr);
 		if (!streamOutput)
@@ -1349,6 +1354,11 @@ bool AdvancedOutput::StartStreaming(obs_service_t *service)
 
 	/* XXX: this is messy and disgusting and should be refactored */
 	if (outputType != type) {
+		streamDelayStarting.Disconnect();
+		streamStopping.Disconnect();
+		startStreaming.Disconnect();
+		stopStreaming.Disconnect();
+
 		streamOutput = obs_output_create(type, "adv_stream",
 				nullptr, nullptr);
 		if (!streamOutput)