aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Antipov2013-10-25 10:55:36 +0400
committerDmitry Antipov2013-10-25 10:55:36 +0400
commit78e0b35c45892995da596c65759fdece3e67129d (patch)
tree4e18a2b9f5703f8eb4c7151fc061f4c13892432e
parent963ce6361af7f8b7aefb63e7a50956e497020b12 (diff)
downloademacs-78e0b35c45892995da596c65759fdece3e67129d.tar.gz
emacs-78e0b35c45892995da596c65759fdece3e67129d.zip
Omit unused frame argument of font API's close function.
* font.h (struct font): Drop frame argument. Adjust comment. * font.c (font_clear_cache, font_close_object): Adjust users. * ftfont.c (ftfont_close): * ftxfont.c (ftxfont_close): * macfont.m (macfont_close): * nsfont.m (nsfont_close): * w32font.c (w32font_close): * xfont.c (xfont_close): * xftfont.c (xftfont_close): Adjust driver-specific close functions, tweak comments and make functions safe if called more than once for the same font object.
-rw-r--r--src/ChangeLog15
-rw-r--r--src/font.c4
-rw-r--r--src/font.h4
-rw-r--r--src/ftfont.c4
-rw-r--r--src/ftxfont.c4
-rw-r--r--src/macfont.m35
-rw-r--r--src/nsfont.m37
-rw-r--r--src/w32font.c30
-rw-r--r--src/xfont.c16
-rw-r--r--src/xftfont.c20
10 files changed, 102 insertions, 67 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 6da470c38ee..cd31196a15a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,18 @@
12013-10-25 Dmitry Antipov <dmantipov@yandex.ru>
2
3 Omit unused frame argument of font API's close function.
4 * font.h (struct font): Drop frame argument. Adjust comment.
5 * font.c (font_clear_cache, font_close_object): Adjust users.
6 * ftfont.c (ftfont_close):
7 * ftxfont.c (ftxfont_close):
8 * macfont.m (macfont_close):
9 * nsfont.m (nsfont_close):
10 * w32font.c (w32font_close):
11 * xfont.c (xfont_close):
12 * xftfont.c (xftfont_close): Adjust driver-specific close
13 functions, tweak comments and make functions safe if called
14 more than once for the same font object.
15
12013-10-24 Glenn Morris <rgm@gnu.org> 162013-10-24 Glenn Morris <rgm@gnu.org>
2 17
3 * Makefile.in (abs_top_srcdir): New, set by configure. 18 * Makefile.in (abs_top_srcdir): New, set by configure.
diff --git a/src/font.c b/src/font.c
index 68db9f2ef2d..aaa02c20e48 100644
--- a/src/font.c
+++ b/src/font.c
@@ -2591,7 +2591,7 @@ font_clear_cache (struct frame *f, Lisp_Object cache, struct font_driver *driver
2591 if (! NILP (AREF (val, FONT_TYPE_INDEX))) 2591 if (! NILP (AREF (val, FONT_TYPE_INDEX)))
2592 { 2592 {
2593 eassert (font && driver == font->driver); 2593 eassert (font && driver == font->driver);
2594 driver->close (f, font); 2594 driver->close (font);
2595 } 2595 }
2596 } 2596 }
2597 if (driver->free_entity) 2597 if (driver->free_entity)
@@ -2892,7 +2892,7 @@ font_close_object (struct frame *f, Lisp_Object font_object)
2892 /* Already closed. */ 2892 /* Already closed. */
2893 return; 2893 return;
2894 FONT_ADD_LOG ("close", font_object, Qnil); 2894 FONT_ADD_LOG ("close", font_object, Qnil);
2895 font->driver->close (f, font); 2895 font->driver->close (font);
2896#ifdef HAVE_WINDOW_SYSTEM 2896#ifdef HAVE_WINDOW_SYSTEM
2897 eassert (FRAME_DISPLAY_INFO (f)->n_fonts); 2897 eassert (FRAME_DISPLAY_INFO (f)->n_fonts);
2898 FRAME_DISPLAY_INFO (f)->n_fonts--; 2898 FRAME_DISPLAY_INFO (f)->n_fonts--;
diff --git a/src/font.h b/src/font.h
index 0ec56590916..9285330ce54 100644
--- a/src/font.h
+++ b/src/font.h
@@ -545,8 +545,8 @@ struct font_driver
545 Lisp_Object (*open) (struct frame *f, Lisp_Object font_entity, 545 Lisp_Object (*open) (struct frame *f, Lisp_Object font_entity,
546 int pixel_size); 546 int pixel_size);
547 547
548 /* Close FONT on frame F. */ 548 /* Close FONT. */
549 void (*close) (struct frame *f, struct font *font); 549 void (*close) (struct font *font);
550 550
551 /* Optional (if FACE->extra is not used). 551 /* Optional (if FACE->extra is not used).
552 Prepare FACE for displaying characters by FONT on frame F by 552 Prepare FACE for displaying characters by FONT on frame F by
diff --git a/src/ftfont.c b/src/ftfont.c
index eeee56891ec..224b8e82500 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -498,7 +498,7 @@ static Lisp_Object ftfont_list (struct frame *, Lisp_Object);
498static Lisp_Object ftfont_match (struct frame *, Lisp_Object); 498static Lisp_Object ftfont_match (struct frame *, Lisp_Object);
499static Lisp_Object ftfont_list_family (struct frame *); 499static Lisp_Object ftfont_list_family (struct frame *);
500static Lisp_Object ftfont_open (struct frame *, Lisp_Object, int); 500static Lisp_Object ftfont_open (struct frame *, Lisp_Object, int);
501static void ftfont_close (struct frame *, struct font *); 501static void ftfont_close (struct font *);
502static int ftfont_has_char (Lisp_Object, int); 502static int ftfont_has_char (Lisp_Object, int);
503static unsigned ftfont_encode_char (struct font *, int); 503static unsigned ftfont_encode_char (struct font *, int);
504static int ftfont_text_extents (struct font *, unsigned *, int, 504static int ftfont_text_extents (struct font *, unsigned *, int,
@@ -1317,7 +1317,7 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
1317} 1317}
1318 1318
1319static void 1319static void
1320ftfont_close (struct frame *f, struct font *font) 1320ftfont_close (struct font *font)
1321{ 1321{
1322 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; 1322 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
1323 Lisp_Object val, cache; 1323 Lisp_Object val, cache;
diff --git a/src/ftxfont.c b/src/ftxfont.c
index 63d03b0e244..8050f292600 100644
--- a/src/ftxfont.c
+++ b/src/ftxfont.c
@@ -260,9 +260,9 @@ ftxfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
260} 260}
261 261
262static void 262static void
263ftxfont_close (struct frame *f, struct font *font) 263ftxfont_close (struct font *font)
264{ 264{
265 ftfont_driver.close (f, font); 265 ftfont_driver.close (font);
266} 266}
267 267
268static int 268static int
diff --git a/src/macfont.m b/src/macfont.m
index b3bf96d8c4e..150aca07651 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -1518,7 +1518,7 @@ static Lisp_Object macfont_match (struct frame *, Lisp_Object);
1518static Lisp_Object macfont_list_family (struct frame *); 1518static Lisp_Object macfont_list_family (struct frame *);
1519static void macfont_free_entity (Lisp_Object); 1519static void macfont_free_entity (Lisp_Object);
1520static Lisp_Object macfont_open (struct frame *, Lisp_Object, int); 1520static Lisp_Object macfont_open (struct frame *, Lisp_Object, int);
1521static void macfont_close (struct frame *, struct font *); 1521static void macfont_close (struct font *);
1522static int macfont_has_char (Lisp_Object, int); 1522static int macfont_has_char (Lisp_Object, int);
1523static unsigned macfont_encode_char (struct font *, int); 1523static unsigned macfont_encode_char (struct font *, int);
1524static int macfont_text_extents (struct font *, unsigned int *, int, 1524static int macfont_text_extents (struct font *, unsigned int *, int,
@@ -2580,23 +2580,28 @@ macfont_open (struct frame * f, Lisp_Object entity, int pixel_size)
2580} 2580}
2581 2581
2582static void 2582static void
2583macfont_close (struct frame * f, struct font *font) 2583macfont_close (struct font *font)
2584{ 2584{
2585 struct macfont_info *macfont_info = (struct macfont_info *) font; 2585 struct macfont_info *macfont_info = (struct macfont_info *) font;
2586 int i;
2587 2586
2588 block_input (); 2587 if (macfont_info->cache)
2589 CFRelease (macfont_info->macfont); 2588 {
2590 CGFontRelease (macfont_info->cgfont); 2589 int i;
2591 if (macfont_info->screen_font) 2590
2592 CFRelease (macfont_info->screen_font); 2591 block_input ();
2593 macfont_release_cache (macfont_info->cache); 2592 CFRelease (macfont_info->macfont);
2594 for (i = 0; i < macfont_info->metrics_nrows; i++) 2593 CGFontRelease (macfont_info->cgfont);
2595 if (macfont_info->metrics[i]) 2594 if (macfont_info->screen_font)
2596 xfree (macfont_info->metrics[i]); 2595 CFRelease (macfont_info->screen_font);
2597 if (macfont_info->metrics) 2596 macfont_release_cache (macfont_info->cache);
2598 xfree (macfont_info->metrics); 2597 macfont_info->cache = NULL;
2599 unblock_input (); 2598 for (i = 0; i < macfont_info->metrics_nrows; i++)
2599 if (macfont_info->metrics[i])
2600 xfree (macfont_info->metrics[i]);
2601 if (macfont_info->metrics)
2602 xfree (macfont_info->metrics);
2603 unblock_input ();
2604 }
2600} 2605}
2601 2606
2602static int 2607static int
diff --git a/src/nsfont.m b/src/nsfont.m
index bd9a2acc983..58663804a2f 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -624,7 +624,7 @@ static Lisp_Object nsfont_match (struct frame *, Lisp_Object);
624static Lisp_Object nsfont_list_family (struct frame *); 624static Lisp_Object nsfont_list_family (struct frame *);
625static Lisp_Object nsfont_open (struct frame *f, Lisp_Object font_entity, 625static Lisp_Object nsfont_open (struct frame *f, Lisp_Object font_entity,
626 int pixel_size); 626 int pixel_size);
627static void nsfont_close (struct frame *f, struct font *font); 627static void nsfont_close (struct font *font);
628static int nsfont_has_char (Lisp_Object entity, int c); 628static int nsfont_has_char (Lisp_Object entity, int c);
629static unsigned int nsfont_encode_char (struct font *font, int c); 629static unsigned int nsfont_encode_char (struct font *font, int c);
630static int nsfont_text_extents (struct font *font, unsigned int *code, 630static int nsfont_text_extents (struct font *font, unsigned int *code,
@@ -929,29 +929,30 @@ nsfont_open (struct frame *f, Lisp_Object font_entity, int pixel_size)
929} 929}
930 930
931 931
932/* Close FONT on frame F. */ 932/* Close FONT. */
933static void 933static void
934nsfont_close (struct frame *f, struct font *font) 934nsfont_close (struct font *font)
935{ 935{
936 struct nsfont_info *font_info = (struct nsfont_info *)font; 936 struct nsfont_info *font_info = (struct nsfont_info *) font;
937 int i;
938
939 /* FIXME: this occurs apparently due to same failure to detect same font
940 that causes need for cache in nsfont_open () */
941 if (!font_info)
942 return;
943 937
944 for (i =0; i<0x100; i++) 938 /* FIXME: font_info may be NULL due to same failure to detect
939 same font that causes need for cache in nsfont_open. */
940 if (font_info && font_info->name)
945 { 941 {
946 xfree (font_info->glyphs[i]); 942 int i;
947 xfree (font_info->metrics[i]); 943
948 } 944 for (i = 0; i < 0x100; i++)
949 [font_info->nsfont release]; 945 {
946 xfree (font_info->glyphs[i]);
947 xfree (font_info->metrics[i]);
948 }
949 [font_info->nsfont release];
950#ifdef NS_IMPL_COCOA 950#ifdef NS_IMPL_COCOA
951 CGFontRelease (font_info->cgfont); 951 CGFontRelease (font_info->cgfont);
952#endif 952#endif
953 xfree (font_info->name); 953 xfree (font_info->name);
954 xfree (font_info); 954 font_info->name = NULL;
955 }
955} 956}
956 957
957 958
diff --git a/src/w32font.c b/src/w32font.c
index 845df68f09d..dd21aca2fa1 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -376,26 +376,26 @@ w32font_open (struct frame *f, Lisp_Object font_entity, int pixel_size)
376 return font_object; 376 return font_object;
377} 377}
378 378
379/* w32 implementation of close for font_backend. 379/* w32 implementation of close for font_backend. */
380 Close FONT on frame F. */
381void 380void
382w32font_close (struct frame *f, struct font *font) 381w32font_close (struct font *font)
383{ 382{
384 int i;
385 struct w32font_info *w32_font = (struct w32font_info *) font; 383 struct w32font_info *w32_font = (struct w32font_info *) font;
386 384
387 /* Delete the GDI font object. */ 385 if (w32_font->hfont)
388 DeleteObject (w32_font->hfont);
389
390 /* Free all the cached metrics. */
391 if (w32_font->cached_metrics)
392 { 386 {
393 for (i = 0; i < w32_font->n_cache_blocks; i++) 387 /* Delete the GDI font object. */
394 { 388 DeleteObject (w32_font->hfont);
395 xfree (w32_font->cached_metrics[i]); 389 w32_font->hfont = NULL;
396 } 390
397 xfree (w32_font->cached_metrics); 391 /* Free all the cached metrics. */
398 w32_font->cached_metrics = NULL; 392 if (w32_font->cached_metrics)
393 {
394 for (i = 0; i < w32_font->n_cache_blocks; i++)
395 xfree (w32_font->cached_metrics[i]);
396 xfree (w32_font->cached_metrics);
397 w32_font->cached_metrics = NULL;
398 }
399 } 399 }
400} 400}
401 401
diff --git a/src/xfont.c b/src/xfont.c
index c5b8db3830c..1f87fb8783e 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -119,7 +119,7 @@ static Lisp_Object xfont_list (struct frame *, Lisp_Object);
119static Lisp_Object xfont_match (struct frame *, Lisp_Object); 119static Lisp_Object xfont_match (struct frame *, Lisp_Object);
120static Lisp_Object xfont_list_family (struct frame *); 120static Lisp_Object xfont_list_family (struct frame *);
121static Lisp_Object xfont_open (struct frame *, Lisp_Object, int); 121static Lisp_Object xfont_open (struct frame *, Lisp_Object, int);
122static void xfont_close (struct frame *, struct font *); 122static void xfont_close (struct font *);
123static int xfont_prepare_face (struct frame *, struct face *); 123static int xfont_prepare_face (struct frame *, struct face *);
124static int xfont_has_char (Lisp_Object, int); 124static int xfont_has_char (Lisp_Object, int);
125static unsigned xfont_encode_char (struct font *, int); 125static unsigned xfont_encode_char (struct font *, int);
@@ -890,11 +890,17 @@ xfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
890} 890}
891 891
892static void 892static void
893xfont_close (struct frame *f, struct font *font) 893xfont_close (struct font *font)
894{ 894{
895 block_input (); 895 struct xfont_info *xfi = (struct xfont_info *) font;
896 XFreeFont (FRAME_X_DISPLAY (f), ((struct xfont_info *) font)->xfont); 896
897 unblock_input (); 897 if (xfi->xfont)
898 {
899 block_input ();
900 XFreeFont (xfi->display, xfi->xfont);
901 unblock_input ();
902 xfi->xfont = NULL;
903 }
898} 904}
899 905
900static int 906static int
diff --git a/src/xftfont.c b/src/xftfont.c
index f2b4c2abe2b..1e03dd320fe 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -486,18 +486,26 @@ xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
486} 486}
487 487
488static void 488static void
489xftfont_close (struct frame *f, struct font *font) 489xftfont_close (struct font *font)
490{ 490{
491 struct xftfont_info *xftfont_info = (struct xftfont_info *) font; 491 struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
492 492
493#ifdef HAVE_LIBOTF 493#ifdef HAVE_LIBOTF
494 if (xftfont_info->otf) 494 if (xftfont_info->otf)
495 OTF_close (xftfont_info->otf); 495 {
496 OTF_close (xftfont_info->otf);
497 xftfont_info->otf = NULL;
498 }
496#endif 499#endif
497 block_input (); 500
498 XftUnlockFace (xftfont_info->xftfont); 501 if (xftfont_info->xftfont)
499 XftFontClose (xftfont_info->display, xftfont_info->xftfont); 502 {
500 unblock_input (); 503 block_input ();
504 XftUnlockFace (xftfont_info->xftfont);
505 XftFontClose (xftfont_info->display, xftfont_info->xftfont);
506 unblock_input ();
507 xftfont_info->xftfont = NULL;
508 }
501} 509}
502 510
503static int 511static int