aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2000-03-27 14:48:33 +0000
committerGerd Moellmann2000-03-27 14:48:33 +0000
commit10168ebbc5f4f1bad0711de93c5c2a329701ad62 (patch)
tree6e111b53d754182d4c0869e2efa1261e3eced90c /src
parenta435fc2a6d3d1e9a83b75cc8650b1fb68bd50d08 (diff)
downloademacs-10168ebbc5f4f1bad0711de93c5c2a329701ad62.tar.gz
emacs-10168ebbc5f4f1bad0711de93c5c2a329701ad62.zip
(x_set_cursor_color): Get color reference counts right.
Diffstat (limited to 'src')
-rw-r--r--src/xfns.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/xfns.c b/src/xfns.c
index 5fe1b4dac19..fed93404f3f 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1520,26 +1520,49 @@ x_set_cursor_color (f, arg, oldval)
1520 Lisp_Object arg, oldval; 1520 Lisp_Object arg, oldval;
1521{ 1521{
1522 unsigned long fore_pixel, pixel; 1522 unsigned long fore_pixel, pixel;
1523 int fore_pixel_allocated_p = 0, pixel_allocated_p = 0;
1523 1524
1524 if (!EQ (Vx_cursor_fore_pixel, Qnil)) 1525 if (!NILP (Vx_cursor_fore_pixel))
1525 fore_pixel = x_decode_color (f, Vx_cursor_fore_pixel, 1526 {
1526 WHITE_PIX_DEFAULT (f)); 1527 fore_pixel = x_decode_color (f, Vx_cursor_fore_pixel,
1528 WHITE_PIX_DEFAULT (f));
1529 fore_pixel_allocated_p = 1;
1530 }
1527 else 1531 else
1528 fore_pixel = f->output_data.x->background_pixel; 1532 fore_pixel = f->output_data.x->background_pixel;
1533
1529 pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); 1534 pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1535 pixel_allocated_p = 1;
1530 1536
1531 /* Make sure that the cursor color differs from the background color. */ 1537 /* Make sure that the cursor color differs from the background color. */
1532 if (pixel == f->output_data.x->background_pixel) 1538 if (pixel == f->output_data.x->background_pixel)
1533 { 1539 {
1540 if (pixel_allocated_p)
1541 {
1542 x_free_colors (f, &pixel, 1);
1543 pixel_allocated_p = 0;
1544 }
1545
1534 pixel = f->output_data.x->mouse_pixel; 1546 pixel = f->output_data.x->mouse_pixel;
1535 if (pixel == fore_pixel) 1547 if (pixel == fore_pixel)
1536 fore_pixel = f->output_data.x->background_pixel; 1548 {
1549 if (fore_pixel_allocated_p)
1550 {
1551 x_free_colors (f, &fore_pixel, 1);
1552 fore_pixel_allocated_p = 0;
1553 }
1554 fore_pixel = f->output_data.x->background_pixel;
1555 }
1537 } 1556 }
1538 1557
1539 unload_color (f, f->output_data.x->cursor_foreground_pixel); 1558 unload_color (f, f->output_data.x->cursor_foreground_pixel);
1559 if (!fore_pixel_allocated_p)
1560 fore_pixel = x_copy_color (f, fore_pixel);
1540 f->output_data.x->cursor_foreground_pixel = fore_pixel; 1561 f->output_data.x->cursor_foreground_pixel = fore_pixel;
1541 1562
1542 unload_color (f, f->output_data.x->cursor_pixel); 1563 unload_color (f, f->output_data.x->cursor_pixel);
1564 if (!pixel_allocated_p)
1565 pixel = x_copy_color (f, pixel);
1543 f->output_data.x->cursor_pixel = pixel; 1566 f->output_data.x->cursor_pixel = pixel;
1544 1567
1545 if (FRAME_X_WINDOW (f) != 0) 1568 if (FRAME_X_WINDOW (f) != 0)