Browse Source

UI: Use deleteLater() rather than explicit delete

When an audio source is removed, it signals its "destroy" callbacks.
One of the callbacks is OBSSourceLabel::SourceDestroyed.  When its Qt
destroy signal is fired, it causes a call to LoadAudioSources to refresh
the source list.  LoadAudioSources deletes the old layout, and so the
QWidget that the OBSSource is based on is freed while it's still in the
middle of running the signal callback, resulting in access to freed
memory.
Richard Stanway 5 years ago
parent
commit
3667e556db
1 changed files with 1 additions and 1 deletions
  1. 1 1
      UI/window-basic-settings.cpp

+ 1 - 1
UI/window-basic-settings.cpp

@@ -2142,7 +2142,7 @@ void OBSBasicSettings::LoadAudioSources()
 {
 	if (ui->audioSourceLayout->rowCount() > 0) {
 		QLayoutItem *forDeletion = ui->audioSourceLayout->takeAt(0);
-		delete forDeletion->widget();
+		forDeletion->widget()->deleteLater();
 		delete forDeletion;
 	}
 	auto layout = new QFormLayout();