]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix X GC leak in GTK and raw (no toolkit) X ports.
authorDmitry Antipov <dmantipov@yandex.ru>
Fri, 2 Aug 2013 13:22:23 +0000 (17:22 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Fri, 2 Aug 2013 13:22:23 +0000 (17:22 +0400)
* xterm.c (x_free_frame_resources): If white and black relief
GCs are allocated, always free them here.
* xfns.c (x_make_gc): Omit redundant initialization.
* widget.c (create_frame_gcs): Remove the leftover.
(EmacsFrameDestroy): Do nothing because all GCs are now freed
in x_free_frame_resources.

src/ChangeLog
src/widget.c
src/xfns.c
src/xterm.c

index dedbe08d9148a079b0bdd4b2d062e759118787df..2a511d2fc8ae43564facac95f7f66499d2ea3f10 100644 (file)
@@ -1,3 +1,13 @@
+2013-08-02  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       Fix X GC leak in GTK and raw (no toolkit) X ports.
+       * xterm.c (x_free_frame_resources): If white and black relief
+       GCs are allocated, always free them here.
+       * xfns.c (x_make_gc): Omit redundant initialization.
+       * widget.c (create_frame_gcs): Remove the leftover.
+       (EmacsFrameDestroy): Do nothing because all GCs are now freed
+       in x_free_frame_resources.
+
 2013-08-02  Jan Djärv  <jan.h.d@swipnet.se>
 
        * nsterm.m (windowWillResize:toSize:): Only change title if
index e2c8e9fa23fe40e2fe0a8667ef8a46681e1875b9..f66ec0b80ec17148de92c2bd215958a8985bc89f 100644 (file)
@@ -503,26 +503,6 @@ widget_update_wm_size_hints (Widget widget)
   update_wm_hints (ew);
 }
 
-
-#if 0
-
-static void
-create_frame_gcs (EmacsFrame ew)
-{
-  struct frame *s = ew->emacs_frame.frame;
-
-  s->output_data.x->normal_gc
-    = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0);
-  s->output_data.x->reverse_gc
-    = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0);
-  s->output_data.x->cursor_gc
-    = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0);
-  s->output_data.x->black_relief.gc = 0;
-  s->output_data.x->white_relief.gc = 0;
-}
-
-#endif /* 0 */
-
 static char setup_frame_cursor_bits[] =
 {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -683,19 +663,7 @@ EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs
 static void
 EmacsFrameDestroy (Widget widget)
 {
-  EmacsFrame ew = (EmacsFrame) widget;
-  struct frame* s = ew->emacs_frame.frame;
-
-  if (! s) emacs_abort ();
-  if (! s->output_data.x) emacs_abort ();
-
-  block_input ();
-  x_free_gcs (s);
-  if (s->output_data.x->white_relief.gc)
-    XFreeGC (XtDisplay (widget), s->output_data.x->white_relief.gc);
-  if (s->output_data.x->black_relief.gc)
-    XFreeGC (XtDisplay (widget), s->output_data.x->black_relief.gc);
-  unblock_input ();
+  /* All GCs are now freed in x_free_frame_resources.  */
 }
 
 static void
index 642bdabb411320fb945ea4cdae7be1aa3f0da0a6..afae67d6327fa3d94e1bc1a74c8de647d1f728fe 100644 (file)
@@ -2788,10 +2788,6 @@ x_make_gc (struct frame *f)
                  | GCFillStyle | GCLineWidth),
                 &gc_values);
 
-  /* Reliefs.  */
-  f->output_data.x->white_relief.gc = 0;
-  f->output_data.x->black_relief.gc = 0;
-
   /* Create the gray border tile used when the pointer is not in
      the frame.  Since this depends on the frame's pixel values,
      this must be done on a per-frame basis.  */
index 83c6dd470d067917d7651ed8dd56001be822b565..9f296d9a82e4ace5dae81821846ddc441258611c 100644 (file)
@@ -9439,6 +9439,19 @@ x_free_frame_resources (struct frame *f)
        unload_color (f, f->output_data.x->black_relief.pixel);
 
       x_free_gcs (f);
+
+      /* Free extra GCs allocated by x_setup_relief_colors.  */
+      if (f->output_data.x->white_relief.gc)
+       {
+         XFreeGC (dpyinfo->display, f->output_data.x->white_relief.gc);
+         f->output_data.x->white_relief.gc = 0;
+       }
+      if (f->output_data.x->black_relief.gc)
+       {
+         XFreeGC (dpyinfo->display, f->output_data.x->black_relief.gc);
+         f->output_data.x->black_relief.gc = 0;
+       }
+
       XFlush (FRAME_X_DISPLAY (f));
     }