changeset 41837:ca8e9acfffca

(x_free_frame_resources) [USE_X_TOOLKIT]: Remove all the scroll bars of the frame before deleting the frame itself. If the frame has a widget, delete the frame with XtDestroyWidget, and do not call XDestroyWindow before that.
author Eli Zaretskii <eliz@gnu.org>
date Thu, 06 Dec 2001 11:56:31 +0000
parents 09535ed6868f
children fd0a005795f3
files src/xterm.c
diffstat 1 files changed, 26 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/xterm.c	Thu Dec 06 09:26:21 2001 +0000
+++ b/src/xterm.c	Thu Dec 06 11:56:31 2001 +0000
@@ -13219,6 +13219,8 @@
      struct frame *f;
 {
   struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+  Lisp_Object bar;
+  struct scroll_bar *b;
 
   BLOCK_INPUT;
 
@@ -13228,23 +13230,40 @@
     {
       if (f->output_data.x->icon_desc)
 	XDestroyWindow (FRAME_X_DISPLAY (f), f->output_data.x->icon_desc);
-      
+
+#ifdef USE_X_TOOLKIT
+      /* Explicitly destroy the scroll bars of the frame.  Without
+	 this, we get "BadDrawable" errors from the toolkit later on,
+	 presumably from expose events generated for the disappearing
+	 toolkit scroll bars.  */
+      for (bar = FRAME_SCROLL_BARS (f); !NILP (bar); bar = b->next)
+	{
+	  b = XSCROLL_BAR (bar);
+	  x_scroll_bar_remove (b);
+	}
+#endif
+
 #ifdef HAVE_X_I18N
       if (FRAME_XIC (f))
 	free_frame_xic (f);
 #endif
-      
-      if (FRAME_X_WINDOW (f))
-	XDestroyWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
-      
+
 #ifdef USE_X_TOOLKIT
       if (f->output_data.x->widget)
 	{
 	  XtDestroyWidget (f->output_data.x->widget);
 	  f->output_data.x->widget = NULL;
 	}
+      /* Tooltips don't have widgets, only a simple X window, even if
+	 we are using a toolkit.  */
+      else if (FRAME_X_WINDOW (f))
+	XDestroyWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
+
       free_frame_menubar (f);
-#endif /* USE_X_TOOLKIT */
+#else  /* !USE_X_TOOLKIT */
+      if (FRAME_X_WINDOW (f))
+	XDestroyWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
+#endif /* !USE_X_TOOLKIT */
 
       unload_color (f, f->output_data.x->foreground_pixel);
       unload_color (f, f->output_data.x->background_pixel);
@@ -13252,7 +13271,7 @@
       unload_color (f, f->output_data.x->cursor_foreground_pixel);
       unload_color (f, f->output_data.x->border_pixel);
       unload_color (f, f->output_data.x->mouse_pixel);
-      
+
       if (f->output_data.x->scroll_bar_background_pixel != -1)
 	unload_color (f, f->output_data.x->scroll_bar_background_pixel);
       if (f->output_data.x->scroll_bar_foreground_pixel != -1)