diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 28f2b7696d..2b6733fb8f 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -1085,17 +1085,11 @@ gdk_win32_window_destroy (GdkWindow *window, _gdk_remove_modal_window (window); /* Remove all our transient children */ - tmp = window_impl->transient_children; - while (tmp != NULL) + while (window_impl->transient_children != NULL) { - GdkWindow *child = tmp->data; - GdkWindowImplWin32 *child_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW (child)->impl); - - child_impl->transient_owner = NULL; - tmp = tmp->next; + GdkWindow *child = window_impl->transient_children->data; + gdk_window_set_transient_for (child, NULL); } - g_slist_free (window_impl->transient_children); - window_impl->transient_children = NULL; #ifdef GDK_WIN32_ENABLE_EGL display = GDK_WIN32_DISPLAY (gdk_window_get_display (window)); @@ -2127,27 +2121,29 @@ gdk_win32_window_set_transient_for (GdkWindow *window, return; } - if (parent == NULL) + if (window_impl->transient_owner == parent) + return; + + if (GDK_IS_WINDOW (window_impl->transient_owner)) { GdkWindowImplWin32 *trans_impl = GDK_WINDOW_IMPL_WIN32 (window_impl->transient_owner->impl); - if (trans_impl->transient_children != NULL) - { - item = g_slist_find (trans_impl->transient_children, window); - item->data = NULL; - trans_impl->transient_children = g_slist_delete_link (trans_impl->transient_children, item); - trans_impl->num_transients--; + item = g_slist_find (trans_impl->transient_children, window); + item->data = NULL; + trans_impl->transient_children = g_slist_delete_link (trans_impl->transient_children, item); + trans_impl->num_transients--; - if (!trans_impl->num_transients) - { - trans_impl->transient_children = NULL; - } + if (!trans_impl->num_transients) + { + trans_impl->transient_children = NULL; } + g_object_unref (G_OBJECT (window_impl->transient_owner)); g_object_unref (G_OBJECT (window)); window_impl->transient_owner = NULL; } - else + + if (parent) { parent_impl = GDK_WINDOW_IMPL_WIN32 (parent->impl);