From fb58e588929f503efa584dc7b600ea12ce198377 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Tue, 21 Dec 2021 01:38:08 -0800 Subject: [PATCH] UI: Use null with sendPostedEvents() After stepping into this function with a debugger, it's been determined that App() won't do anything because it'll marked as a recursive call, and 'this' will only clear events for this specific object. Instead, we should be using nullptr to send all posted events for the program. This fixes an issue where posted events would not be processed on shutdown as expected before destroying the main window. --- UI/window-basic-main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 4bf1b7879..51dcd3c86 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -960,7 +960,7 @@ void OBSBasic::LoadData(obs_data_t *data, const char *file) devicePropertiesThread.reset(); } - QApplication::sendPostedEvents(this); + QApplication::sendPostedEvents(nullptr); OBSDataAutoRelease modulesObj = obs_data_get_obj(data, "modules"); if (api) @@ -2554,7 +2554,7 @@ void OBSBasic::ClearHotkeys() OBSBasic::~OBSBasic() { /* clear out UI event queue */ - QApplication::sendPostedEvents(App()); + QApplication::sendPostedEvents(nullptr); if (updateCheckThread && updateCheckThread->isRunning()) updateCheckThread->wait(); @@ -2637,7 +2637,7 @@ OBSBasic::~OBSBasic() * but Qt doesn't use C++ in a normal way, so you can't really rely on * normal C++ behavior for your data to be freed in the order that you * expect or want it to. */ - QApplication::sendPostedEvents(this); + QApplication::sendPostedEvents(nullptr); config_set_int(App()->GlobalConfig(), "General", "LastVersion", LIBOBS_API_VER); @@ -4641,7 +4641,7 @@ void OBSBasic::closeEvent(QCloseEvent *event) devicePropertiesThread.reset(); } - QApplication::sendPostedEvents(this); + QApplication::sendPostedEvents(nullptr); signalHandlers.clear();