From c4ef2522ad5c7d0f133f0cf3fb910eee9755176d Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 18 Mar 2015 06:19:18 -0700 Subject: [PATCH] UI: Destroy save timer before closing main window This prevents the save timer from unexpectedly going off during the middle of the save process. --- obs/window-basic-main.cpp | 13 ++++++++----- obs/window-basic-main.hpp | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index b6a8775af..1ad6c68bf 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -653,15 +653,13 @@ void OBSBasic::OBSInit() TimedCheckForUpdates(); loaded = true; - QTimer *timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(SaveProject())); - timer->start(20000); + saveTimer = new QTimer(this); + connect(saveTimer, SIGNAL(timeout()), this, SLOT(SaveProject())); + saveTimer->start(20000); } OBSBasic::~OBSBasic() { - SaveProject(); - /* XXX: any obs data must be released before calling obs_shutdown. * currently, we can't automate this with C++ RAII because of the * delicate nature of obs_shutdown needing to be freed before the UI @@ -1659,6 +1657,11 @@ void OBSBasic::closeEvent(QCloseEvent *event) // remove draw callback in case our drawable surfaces go away before // the destructor gets called obs_remove_draw_callback(OBSBasic::RenderMain, this); + + /* Delete the save timer so it doesn't trigger after this point while + * the program data is being freed */ + delete saveTimer; + SaveProject(); } void OBSBasic::changeEvent(QEvent *event) diff --git a/obs/window-basic-main.hpp b/obs/window-basic-main.hpp index 08f6523c2..da43b89b6 100644 --- a/obs/window-basic-main.hpp +++ b/obs/window-basic-main.hpp @@ -61,6 +61,8 @@ private: bool loaded = false; + QPointer saveTimer; + QPointer interaction; QPointer properties; QPointer transformWindow;