mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-06-28 09:59:41 -06:00
prevent use after free through focusOutEvent when window is closed
This commit is contained in:
@ -780,6 +780,10 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
||||
Config::Save();
|
||||
|
||||
emuInstance->deleteWindow(windowID, false);
|
||||
|
||||
// emuInstance may be deleted
|
||||
// prevent use after free from us
|
||||
emuInstance = nullptr;
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
@ -970,7 +974,10 @@ void MainWindow::focusInEvent(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)
|
||||
|
Reference in New Issue
Block a user