Explorar o código

frontend-tools: Fix multiple signal-slot connections on Output Timer

When running an Output Timer multiple times, multiple signal-slot
connections would be made with the corresponding output stop event
functions. This would cause later Output Timers to terminate
unexpectedly early, due to the stop functions having been called
repeatedly on previous Output Timer runs while outputs were stopping.

There may still be an underlying bug with calling stop on outputs
repeatedly, but this change at least ensures that Output Timers only
call their stop functions once.
Matt %!s(int64=2) %!d(string=hai) anos
pai
achega
93f5b45be8
Modificáronse 1 ficheiros con 9 adicións e 12 borrados
  1. 9 12
      UI/frontend-plugins/frontend-tools/output-timer.cpp

+ 9 - 12
UI/frontend-plugins/frontend-tools/output-timer.cpp

@@ -32,6 +32,15 @@ OutputTimer::OutputTimer(QWidget *parent)
 
 	recordingTimer = new QTimer(this);
 	recordingTimerDisplay = new QTimer(this);
+
+	QObject::connect(streamingTimer, &QTimer::timeout, this,
+			 &OutputTimer::EventStopStreaming);
+	QObject::connect(streamingTimerDisplay, &QTimer::timeout, this,
+			 &OutputTimer::UpdateStreamTimerDisplay);
+	QObject::connect(recordingTimer, &QTimer::timeout, this,
+			 &OutputTimer::EventStopRecording);
+	QObject::connect(recordingTimerDisplay, &QTimer::timeout, this,
+			 &OutputTimer::UpdateRecordTimerDisplay);
 }
 
 void OutputTimer::closeEvent(QCloseEvent *)
@@ -86,12 +95,6 @@ void OutputTimer::StreamTimerStart()
 	streamingTimer->setInterval(total);
 	streamingTimer->setSingleShot(true);
 
-	QObject::connect(streamingTimer, &QTimer::timeout, this,
-			 &OutputTimer::EventStopStreaming);
-
-	QObject::connect(streamingTimerDisplay, &QTimer::timeout, this,
-			 &OutputTimer::UpdateStreamTimerDisplay);
-
 	streamingTimer->start();
 	streamingTimerDisplay->start(1000);
 	ui->outputTimerStream->setText(obs_module_text("Stop"));
@@ -120,12 +123,6 @@ void OutputTimer::RecordTimerStart()
 	recordingTimer->setInterval(total);
 	recordingTimer->setSingleShot(true);
 
-	QObject::connect(recordingTimer, &QTimer::timeout, this,
-			 &OutputTimer::EventStopRecording);
-
-	QObject::connect(recordingTimerDisplay, &QTimer::timeout, this,
-			 &OutputTimer::UpdateRecordTimerDisplay);
-
 	recordingTimer->start();
 	recordingTimerDisplay->start(1000);
 	ui->outputTimerRecord->setText(obs_module_text("Stop"));