From 19b69bbdc23a58a97faf88f0fff591b958dffef4 Mon Sep 17 00:00:00 2001 From: Jonian Guveli Date: Thu, 25 Jul 2024 11:04:57 +0300 Subject: [PATCH] Qt: Stop emuThread on closeEvent --- include/panda_qt/main_window.hpp | 1 + src/panda_qt/main_window.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/panda_qt/main_window.hpp b/include/panda_qt/main_window.hpp index c99fb4c2..ecdbc02e 100644 --- a/include/panda_qt/main_window.hpp +++ b/include/panda_qt/main_window.hpp @@ -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; diff --git a/src/panda_qt/main_window.cpp b/src/panda_qt/main_window.cpp index 1f9b8123..284e88ea 100644 --- a/src/panda_qt/main_window.cpp +++ b/src/panda_qt/main_window.cpp @@ -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;