prevent use after free through focusOutEvent when window is closed
This commit is contained in:
parent
2179ca2a41
commit
2eb6d44c2c
|
@ -780,6 +780,10 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
||||||
Config::Save();
|
Config::Save();
|
||||||
|
|
||||||
emuInstance->deleteWindow(windowID, false);
|
emuInstance->deleteWindow(windowID, false);
|
||||||
|
|
||||||
|
// emuInstance may be deleted
|
||||||
|
// prevent use after free from us
|
||||||
|
emuInstance = nullptr;
|
||||||
QMainWindow::closeEvent(event);
|
QMainWindow::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -970,7 +974,10 @@ void MainWindow::focusInEvent(QFocusEvent* event)
|
||||||
|
|
||||||
void MainWindow::focusOutEvent(QFocusEvent* event)
|
void MainWindow::focusOutEvent(QFocusEvent* event)
|
||||||
{
|
{
|
||||||
emuInstance->audioMute();
|
// focusOutEvent is called through the window close event handler
|
||||||
|
// prevent use after free
|
||||||
|
if (emuInstance)
|
||||||
|
emuInstance->audioMute();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onAppStateChanged(Qt::ApplicationState state)
|
void MainWindow::onAppStateChanged(Qt::ApplicationState state)
|
||||||
|
|
Loading…
Reference in New Issue