From: Mike Hommey <mh@glandium.org>
Date: Thu, 25 Feb 2010 15:19:00 +0100
Subject: Handle side-effect sibling destruction when destroying child windows

https://bugzilla.mozilla.org/show_bug.cgi?id=528386
---
 widget/src/gtk2/nsWindow.cpp |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp
index 5ef0d4d..6fa1df6 100644
--- a/widget/src/gtk2/nsWindow.cpp
+++ b/widget/src/gtk2/nsWindow.cpp
@@ -719,9 +719,7 @@ nsWindow::DestroyChildWindows()
     if (!mGdkWindow)
         return;
 
-    GList *children = gdk_window_get_children(mGdkWindow);
-
-    for(GList *list = children; list; list = list->next) {
+    while (GList *children = gdk_window_peek_children(mGdkWindow)) {
         GdkWindow *child = GDK_WINDOW(children->data);
         nsWindow *kid = get_window_for_gdk_window(child);
         if (kid) {
@@ -736,8 +734,6 @@ nsWindow::DestroyChildWindows()
             }
         }
     }
-
-    g_list_free(children);
 }
 
 NS_IMETHODIMP
