فهرست منبع

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 6 سال پیش
والد
کامیت
3667e556db
1فایلهای تغییر یافته به همراه1 افزوده شده و 1 حذف شده
  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) {
 	if (ui->audioSourceLayout->rowCount() > 0) {
 		QLayoutItem *forDeletion = ui->audioSourceLayout->takeAt(0);
 		QLayoutItem *forDeletion = ui->audioSourceLayout->takeAt(0);
-		delete forDeletion->widget();
+		forDeletion->widget()->deleteLater();
 		delete forDeletion;
 		delete forDeletion;
 	}
 	}
 	auto layout = new QFormLayout();
 	auto layout = new QFormLayout();