Fix crash quitting application due to iterating over a changing list. (flutter/engine#55062)

Detected as the FlPlatformHandlerTest.ExitApplicationDispose was
crashing sometimes, valgrind showed invalid memory access.
This commit is contained in:
Robert Ancell
2024-09-12 09:40:45 +12:00
committed by GitHub
parent a89c2ae2a4
commit 2a10ec7c44

View File

@@ -192,7 +192,10 @@ static void quit_application() {
// Break them so the application object can cleanup.
// See https://gitlab.gnome.org/GNOME/gtk/-/issues/6190
if (GTK_IS_APPLICATION(app)) {
GList* windows = gtk_application_get_windows(GTK_APPLICATION(app));
// List is copied as it will be modified as windows are disconnected from
// the application.
g_autoptr(GList) windows =
g_list_copy(gtk_application_get_windows(GTK_APPLICATION(app)));
for (GList* link = windows; link != NULL; link = link->next) {
GtkWidget* window = GTK_WIDGET(link->data);
gtk_window_set_application(GTK_WINDOW(window), NULL);