From 6b3d30ef03198d1b9a3335deb40ede8e2e975986 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 18 Mar 2015 06:31:08 -0700 Subject: [PATCH] UI: Flush event queue before obs_shutdown Sometimes events with rogue source references are in the event queue when the program is shutting down. This can cause the program to reference freed data. Processing those remaining events before shutting down solves the issue. --- obs/window-basic-main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index 1ad6c68bf..40f9be4e9 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -692,6 +692,15 @@ OBSBasic::~OBSBasic() gs_vertexbuffer_destroy(circle); obs_leave_graphics(); + /* When shutting down, sometimes source references can get in to the + * event queue, and if we don't forcibly process those events they + * won't get processed until after obs_shutdown has been called. I + * really wish there were a more elegant way to deal with this via C++, + * 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); + obs_shutdown(); config_set_int(App()->GlobalConfig(), "General", "LastVersion",