Преглед на файлове

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.
jp9000 преди 10 години
родител
ревизия
6b3d30ef03
променени са 1 файла, в които са добавени 9 реда и са изтрити 0 реда
  1. 9 0
      obs/window-basic-main.cpp

+ 9 - 0
obs/window-basic-main.cpp

@@ -692,6 +692,15 @@ OBSBasic::~OBSBasic()
 	gs_vertexbuffer_destroy(circle);
 	gs_vertexbuffer_destroy(circle);
 	obs_leave_graphics();
 	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();
 	obs_shutdown();
 
 
 	config_set_int(App()->GlobalConfig(), "General", "LastVersion",
 	config_set_int(App()->GlobalConfig(), "General", "LastVersion",