reparenting toplevel windows crash



With current nautilus i get a lot of crashes in the event loop.
This happens because there is a freed pointer in the xid hash, due to a
toplevel window being reparented to a child window, leaving the freed
toplevel->focus_window in the hash table.

The attached patch fixes it for me. 

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a leather-clad pirate cop on a search for his missing sister. She's a 
violent hip-hop mermaid from beyond the grave. They fight crime! 
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.4693
diff -u -p -r1.4693 ChangeLog
--- ChangeLog	8 Dec 2003 23:38:54 -0000	1.4693
+++ ChangeLog	9 Dec 2003 15:13:07 -0000
@@ -1,3 +1,8 @@
+2003-12-09  Alexander Larsson  <alexl redhat com>
+
+	* gdk/x11/gdkwindow-x11.c (gdk_window_reparent):
+	Make sure to remove focus_window from xid hash when the toplevel is destroyed
+
 2003-12-08  Jan Arne Petersen  <jpetersen uni-bonn de>
 
 	* gtk/gtkfilechooserdefault.c:
Index: gdk/x11/gdkwindow-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkwindow-x11.c,v
retrieving revision 1.195
diff -u -p -r1.195 gdkwindow-x11.c
--- gdk/x11/gdkwindow-x11.c	23 Oct 2003 18:50:40 -0000	1.195
+++ gdk/x11/gdkwindow-x11.c	9 Dec 2003 15:13:11 -0000
@@ -1526,6 +1526,11 @@ gdk_window_reparent (GdkWindow *window,
 	  GDK_WINDOW_TYPE (window) = GDK_WINDOW_CHILD;
 	  if (impl->toplevel)
 	    {
+	      if (impl->toplevel->focus_window)
+		{
+		  _gdk_xid_table_remove (GDK_WINDOW_DISPLAY (window), impl->toplevel->focus_window);
+		  XDestroyWindow (GDK_WINDOW_XDISPLAY (window), impl->toplevel->focus_window);
+		}
 	      gdk_toplevel_x11_free_contents (impl->toplevel);
 	      g_free (impl->toplevel);
 	      impl->toplevel = NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]