From 5fc47dce6af03b004cdcb028e471420cb8c04b23 Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Thu, 30 Dec 2021 21:38:23 -0500 Subject: [PATCH] Added logic to force orderly close of Qt TAS editor any time a ROM is closed or the application is quit. --- src/drivers/Qt/ConsoleWindow.cpp | 5 +++++ src/drivers/Qt/TasEditor/TasEditorWindow.cpp | 16 ++++++++++++++++ src/drivers/Qt/TasEditor/TasEditorWindow.h | 2 ++ src/drivers/Qt/fceuWrapper.cpp | 6 ++++++ 4 files changed, 29 insertions(+) diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index 9a689c40..d3bd3616 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -2113,6 +2113,11 @@ void consoleWin_t::closeApp(void) aviDiskThread->quit(); aviDiskThread->wait( 10000 ); + if ( tasWin != NULL ) + { + tasWin->requestWindowClose(); + } + FCEU_WRAPPER_LOCK(); fceuWrapperClose(); FCEU_WRAPPER_UNLOCK(); diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp index 53fcd713..2d41ad50 100644 --- a/src/drivers/Qt/TasEditor/TasEditorWindow.cpp +++ b/src/drivers/Qt/TasEditor/TasEditorWindow.cpp @@ -297,6 +297,7 @@ void TasEditorWindow::closeEvent(QCloseEvent *event) event->ignore(); return; } + project.reset(); done(0); deleteLater(); @@ -309,11 +310,26 @@ void TasEditorWindow::closeWindow(void) { return; } + project.reset(); + printf("Tas Editor Close Window\n"); done(0); deleteLater(); } //---------------------------------------------------------------------------- +int TasEditorWindow::requestWindowClose(void) +{ + askToSaveProject(); + + project.reset(); + + printf("Tas Editor Close Window\n"); + done(0); + deleteLater(); + + return 0; +} +//---------------------------------------------------------------------------- QMenuBar *TasEditorWindow::buildMenuBar(void) { QMenu *fileMenu, *editMenu, *viewMenu, diff --git a/src/drivers/Qt/TasEditor/TasEditorWindow.h b/src/drivers/Qt/TasEditor/TasEditorWindow.h index cf598d35..855476fa 100644 --- a/src/drivers/Qt/TasEditor/TasEditorWindow.h +++ b/src/drivers/Qt/TasEditor/TasEditorWindow.h @@ -411,6 +411,8 @@ class TasEditorWindow : public QDialog bool handleInputColumnSetUsingPattern(int joy, int button); bool updateHistoryItems(void); + int requestWindowClose(void); + QPoint getPreviewPopupCoordinates(void); protected: diff --git a/src/drivers/Qt/fceuWrapper.cpp b/src/drivers/Qt/fceuWrapper.cpp index 1098d492..bc56a408 100644 --- a/src/drivers/Qt/fceuWrapper.cpp +++ b/src/drivers/Qt/fceuWrapper.cpp @@ -44,6 +44,7 @@ #include "Qt/ConsoleDebugger.h" #include "Qt/ConsoleWindow.h" #include "Qt/ConsoleUtilities.h" +#include "Qt/TasEditor/TasEditorWindow.h" #include "Qt/fceux_git_info.h" #include "common/cheat.h" @@ -483,6 +484,11 @@ CloseGame(void) saveInputSettingsToFile(); } + if ( tasWin != NULL ) + { + tasWin->requestWindowClose(); + } + FCEUI_CloseGame(); DriverKill();