Qt: Stop emuThread on closeEvent

This commit is contained in:
Jonian Guveli 2024-07-25 11:04:57 +03:00
parent df5d14e3d8
commit 19b69bbdc2
2 changed files with 8 additions and 2 deletions

View file

@ -139,6 +139,7 @@ class MainWindow : public QMainWindow {
MainWindow(QApplication* app, QWidget* parent = nullptr);
~MainWindow();
void closeEvent(QCloseEvent *event) override;
void keyPressEvent(QKeyEvent* event) override;
void keyReleaseEvent(QKeyEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;

View file

@ -204,14 +204,19 @@ void MainWindow::selectLuaFile() {
}
}
// Cleanup when the main window closes
MainWindow::~MainWindow() {
// Stop emulator thread when the main window closes
void MainWindow::closeEvent(QCloseEvent *event) {
appRunning = false; // Set our running atomic to false in order to make the emulator thread stop, and join it
if (emuThread.joinable()) {
emuThread.join();
}
SDL_Quit();
}
// Cleanup when the main window closes
MainWindow::~MainWindow() {
delete emu;
delete menuBar;
delete aboutWindow;