[beast: 7/8] GXK: widget_lower_windows: fix invalid GdkWindow child list modifications
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 7/8] GXK: widget_lower_windows: fix invalid GdkWindow child list modifications
- Date: Wed, 23 Sep 2015 09:06:45 +0000 (UTC)
commit 74a70adeb7c5d30c993df69ca804e27b51c1312b
Author: Tim Janik <timj gnu org>
Date: Tue Sep 22 00:43:24 2015 +0200
GXK: widget_lower_windows: fix invalid GdkWindow child list modifications
While iterating over a window's child list, the code used to modify the
very list by calling gdk_window_lower(). This could lead to occasional
crashes or assertion warnings.
beast-gtk/gxk/gxkauxwidgets.cc | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/beast-gtk/gxk/gxkauxwidgets.cc b/beast-gtk/gxk/gxkauxwidgets.cc
index 4948a5d..e82b1fa 100644
--- a/beast-gtk/gxk/gxkauxwidgets.cc
+++ b/beast-gtk/gxk/gxkauxwidgets.cc
@@ -503,14 +503,19 @@ widget_mute_events (GtkWidget *widget,
static void
widget_lower_windows (GtkWidget *widget)
{
- GList *list = gdk_window_peek_children (widget->window);
- for (; list; list = list->next)
+ std::vector<GdkWindow*> wins;
+ // gdk_window_peek_children's result is modified by gdk_window_lower
+ for (GList *list = gdk_window_peek_children (widget->window); list; list = list->next)
{
- gpointer user_data;
- gdk_window_get_user_data ((GdkWindow*) list->data, &user_data);
+ GdkWindow *win = (GdkWindow*) list->data;
+ gpointer user_data = NULL;
+ gdk_window_get_user_data (win, &user_data);
if (user_data == (gpointer) widget)
- gdk_window_lower ((GdkWindow*) list->data);
+ wins.push_back (win);
}
+ // so here we walk the list of windows that need lowering
+ for (GdkWindow *win : wins)
+ gdk_window_lower (win);
}
static void
widget_hide_insensitive (GtkWidget *widget)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]