aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2013-08-02 17:22:23 +0400
committerDmitry Antipov2013-08-02 17:22:23 +0400
commit4b5c9326ce8f6b7856437cbbdbcccb415b38a5fc (patch)
tree797f94ac354fa4eaa7d3b8dc43590fa7824ddf0d /src
parent26bb8a7ceb23a748e35afbc895b54e8c1322298f (diff)
downloademacs-4b5c9326ce8f6b7856437cbbdbcccb415b38a5fc.tar.gz
emacs-4b5c9326ce8f6b7856437cbbdbcccb415b38a5fc.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog10
-rw-r--r--src/widget.c34
-rw-r--r--src/xfns.c4
-rw-r--r--src/xterm.c13
4 files changed, 24 insertions, 37 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index dedbe08d914..2a511d2fc8a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,13 @@
12013-08-02 Dmitry Antipov <dmantipov@yandex.ru>
2
3 Fix X GC leak in GTK and raw (no toolkit) X ports.
4 * xterm.c (x_free_frame_resources): If white and black relief
5 GCs are allocated, always free them here.
6 * xfns.c (x_make_gc): Omit redundant initialization.
7 * widget.c (create_frame_gcs): Remove the leftover.
8 (EmacsFrameDestroy): Do nothing because all GCs are now freed
9 in x_free_frame_resources.
10
12013-08-02 Jan Djärv <jan.h.d@swipnet.se> 112013-08-02 Jan Djärv <jan.h.d@swipnet.se>
2 12
3 * nsterm.m (windowWillResize:toSize:): Only change title if 13 * nsterm.m (windowWillResize:toSize:): Only change title if
diff --git a/src/widget.c b/src/widget.c
index e2c8e9fa23f..f66ec0b80ec 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -503,26 +503,6 @@ widget_update_wm_size_hints (Widget widget)
503 update_wm_hints (ew); 503 update_wm_hints (ew);
504} 504}
505 505
506
507#if 0
508
509static void
510create_frame_gcs (EmacsFrame ew)
511{
512 struct frame *s = ew->emacs_frame.frame;
513
514 s->output_data.x->normal_gc
515 = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0);
516 s->output_data.x->reverse_gc
517 = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0);
518 s->output_data.x->cursor_gc
519 = XCreateGC (XtDisplay (ew), RootWindowOfScreen (XtScreen (ew)), 0, 0);
520 s->output_data.x->black_relief.gc = 0;
521 s->output_data.x->white_relief.gc = 0;
522}
523
524#endif /* 0 */
525
526static char setup_frame_cursor_bits[] = 506static char setup_frame_cursor_bits[] =
527{ 507{
528 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 508 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -683,19 +663,7 @@ EmacsFrameRealize (Widget widget, XtValueMask *mask, XSetWindowAttributes *attrs
683static void 663static void
684EmacsFrameDestroy (Widget widget) 664EmacsFrameDestroy (Widget widget)
685{ 665{
686 EmacsFrame ew = (EmacsFrame) widget; 666 /* All GCs are now freed in x_free_frame_resources. */
687 struct frame* s = ew->emacs_frame.frame;
688
689 if (! s) emacs_abort ();
690 if (! s->output_data.x) emacs_abort ();
691
692 block_input ();
693 x_free_gcs (s);
694 if (s->output_data.x->white_relief.gc)
695 XFreeGC (XtDisplay (widget), s->output_data.x->white_relief.gc);
696 if (s->output_data.x->black_relief.gc)
697 XFreeGC (XtDisplay (widget), s->output_data.x->black_relief.gc);
698 unblock_input ();
699} 667}
700 668
701static void 669static void
diff --git a/src/xfns.c b/src/xfns.c
index 642bdabb411..afae67d6327 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -2788,10 +2788,6 @@ x_make_gc (struct frame *f)
2788 | GCFillStyle | GCLineWidth), 2788 | GCFillStyle | GCLineWidth),
2789 &gc_values); 2789 &gc_values);
2790 2790
2791 /* Reliefs. */
2792 f->output_data.x->white_relief.gc = 0;
2793 f->output_data.x->black_relief.gc = 0;
2794
2795 /* Create the gray border tile used when the pointer is not in 2791 /* Create the gray border tile used when the pointer is not in
2796 the frame. Since this depends on the frame's pixel values, 2792 the frame. Since this depends on the frame's pixel values,
2797 this must be done on a per-frame basis. */ 2793 this must be done on a per-frame basis. */
diff --git a/src/xterm.c b/src/xterm.c
index 83c6dd470d0..9f296d9a82e 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -9439,6 +9439,19 @@ x_free_frame_resources (struct frame *f)
9439 unload_color (f, f->output_data.x->black_relief.pixel); 9439 unload_color (f, f->output_data.x->black_relief.pixel);
9440 9440
9441 x_free_gcs (f); 9441 x_free_gcs (f);
9442
9443 /* Free extra GCs allocated by x_setup_relief_colors. */
9444 if (f->output_data.x->white_relief.gc)
9445 {
9446 XFreeGC (dpyinfo->display, f->output_data.x->white_relief.gc);
9447 f->output_data.x->white_relief.gc = 0;
9448 }
9449 if (f->output_data.x->black_relief.gc)
9450 {
9451 XFreeGC (dpyinfo->display, f->output_data.x->black_relief.gc);
9452 f->output_data.x->black_relief.gc = 0;
9453 }
9454
9442 XFlush (FRAME_X_DISPLAY (f)); 9455 XFlush (FRAME_X_DISPLAY (f));
9443 } 9456 }
9444 9457