proof all dialogs against use-after-free when closing main window while a dialog is open

This commit is contained in:
Arisotura 2024-10-27 14:24:59 +01:00
parent a61754bb58
commit f2dce621ce
11 changed files with 90 additions and 0 deletions

View File

@ -170,6 +170,12 @@ void AudioSettingsDialog::on_AudioSettingsDialog_accepted()
void AudioSettingsDialog::on_AudioSettingsDialog_rejected()
{
if (!((MainWindow*)parent())->getEmuInstance())
{
closeDlg();
return;
}
auto& cfg = emuInstance->getGlobalConfig();
auto& instcfg = emuInstance->getLocalConfig();
cfg.SetInt("Audio.Interpolation", oldInterp);

View File

@ -163,6 +163,12 @@ void CameraSettingsDialog::on_CameraSettingsDialog_accepted()
void CameraSettingsDialog::on_CameraSettingsDialog_rejected()
{
if (!((MainWindow*)parent())->getEmuInstance())
{
closeDlg();
return;
}
for (int i = 0; i < 2; i++)
{
camManager[i]->stop();

View File

@ -215,6 +215,13 @@ void EmuSettingsDialog::verifyFirmware()
void EmuSettingsDialog::done(int r)
{
if (!((MainWindow*)parent())->getEmuInstance())
{
QDialog::done(r);
closeDlg();
return;
}
needsReset = false;
if (r == QDialog::Accepted)

View File

@ -132,6 +132,13 @@ bool FirmwareSettingsDialog::verifyMAC()
void FirmwareSettingsDialog::done(int r)
{
if (!((MainWindow*)parent())->getEmuInstance())
{
QDialog::done(r);
closeDlg();
return;
}
needsReset = false;
if (r == QDialog::Accepted)

View File

@ -104,6 +104,13 @@ void InterfaceSettingsDialog::on_pbQuarter_clicked()
void InterfaceSettingsDialog::done(int r)
{
if (!((MainWindow*)parent())->getEmuInstance())
{
QDialog::done(r);
closeDlg();
return;
}
if (r == QDialog::Accepted)
{
auto& cfg = emuInstance->getGlobalConfig();

View File

@ -65,6 +65,12 @@ LANStartHostDialog::~LANStartHostDialog()
void LANStartHostDialog::done(int r)
{
if (!((MainWindow*)parent())->getEmuInstance())
{
QDialog::done(r);
return;
}
if (r == QDialog::Accepted)
{
if (ui->txtPlayerName->text().trimmed().isEmpty())
@ -186,6 +192,12 @@ void LANStartClientDialog::onDirectConnect()
void LANStartClientDialog::done(int r)
{
if (!((MainWindow*)parent())->getEmuInstance())
{
QDialog::done(r);
return;
}
if (r == QDialog::Accepted)
{
if (ui->txtPlayerName->text().trimmed().isEmpty())
@ -313,6 +325,12 @@ void LANDialog::on_btnLeaveGame_clicked()
void LANDialog::done(int r)
{
if (!((MainWindow*)parent())->getEmuInstance())
{
QDialog::done(r);
return;
}
bool showwarning = true;
if (lan().GetNumPlayers() < 2)
showwarning = false;

View File

@ -59,6 +59,13 @@ MPSettingsDialog::~MPSettingsDialog()
void MPSettingsDialog::done(int r)
{
if (!((MainWindow*)parent())->getEmuInstance())
{
QDialog::done(r);
closeDlg();
return;
}
if (r == QDialog::Accepted)
{
auto& cfg = emuInstance->getGlobalConfig();

View File

@ -63,6 +63,12 @@ NetplayStartHostDialog::~NetplayStartHostDialog()
void NetplayStartHostDialog::done(int r)
{
if (!((MainWindow*)parent())->getEmuInstance())
{
QDialog::done(r);
return;
}
if (r == QDialog::Accepted)
{
std::string player = ui->txtPlayerName->text().toStdString();
@ -94,6 +100,12 @@ NetplayStartClientDialog::~NetplayStartClientDialog()
void NetplayStartClientDialog::done(int r)
{
if (!((MainWindow*)parent())->getEmuInstance())
{
QDialog::done(r);
return;
}
if (r == QDialog::Accepted)
{
std::string player = ui->txtPlayerName->text().toStdString();

View File

@ -72,6 +72,13 @@ PathSettingsDialog::~PathSettingsDialog()
void PathSettingsDialog::done(int r)
{
if (!((MainWindow*)parent())->getEmuInstance())
{
QDialog::done(r);
closeDlg();
return;
}
needsReset = false;
if (r == QDialog::Accepted)

View File

@ -121,6 +121,12 @@ void VideoSettingsDialog::on_VideoSettingsDialog_accepted()
void VideoSettingsDialog::on_VideoSettingsDialog_rejected()
{
if (!((MainWindow*)parent())->getEmuInstance())
{
closeDlg();
return;
}
bool old_gl = UsesGL();
auto& cfg = emuInstance->getGlobalConfig();

View File

@ -94,6 +94,13 @@ WifiSettingsDialog::~WifiSettingsDialog()
void WifiSettingsDialog::done(int r)
{
if (!((MainWindow*)parent())->getEmuInstance())
{
QDialog::done(r);
closeDlg();
return;
}
needsReset = false;
if (r == QDialog::Accepted)