From 62c480c90a5fedee7dfa7d4d3c7c045ca9e0e892 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Dj=C3=A4rv?= Date: Mon, 8 Oct 2012 20:31:39 +0200 Subject: [PATCH] Fix wide-int related error and cache error in NS font handling. * nsfont.m (Vfonts_in_cache): New variable. (nsfont_open): Use unsignedLongLongValue for cache in case wide ints are used. Add cached fonts to Vfonts_in_cache. (syms_of_nsfont): Initialize and staticpro Vfonts_in_cache. --- src/ChangeLog | 7 +++++++ src/nsfont.m | 19 ++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 122e0d1965..b348ec0653 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2012-10-08 Jan Djärv + + * nsfont.m (Vfonts_in_cache): New variable. + (nsfont_open): Use unsignedLongLongValue for cache in case wide ints + are used. Add cached fonts to Vfonts_in_cache. + (syms_of_nsfont): Initialize and staticpro Vfonts_in_cache. + 2012-10-08 Juanma Barranquero * makefile.w32-in (LOCAL_FLAGS): Don't define HAVE_NTGUI, it's now diff --git a/src/nsfont.m b/src/nsfont.m index b13c96aa6e..20a8f5d402 100644 --- a/src/nsfont.m +++ b/src/nsfont.m @@ -53,6 +53,9 @@ extern float ns_antialias_threshold; extern int ns_tmp_flags; extern struct nsfont_info *ns_tmp_font; +static Lisp_Object Vfonts_in_cache; + + /* font glyph and metrics caching functions, implemented at end */ static void ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block); @@ -799,8 +802,7 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) { if (NSFONT_TRACE) fprintf(stderr, "*** nsfont_open CACHE HIT!\n"); - /* FIXME: Cast from (unsigned long) to Lisp_Object. */ - XHASH (font_object) = [cached unsignedLongValue]; + XHASH (font_object) = [cached unsignedLongLongValue]; return font_object; } else @@ -808,9 +810,13 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) font_object = font_make_object (VECSIZE (struct nsfont_info), font_entity, pixel_size); if (!synthItal) - [fontCache setObject: [NSNumber numberWithUnsignedLong: - (unsigned long) XHASH (font_object)] - forKey: nsfont]; + { + [fontCache setObject: [NSNumber + numberWithUnsignedLongLong: + (unsigned long long) XHASH (font_object)] + forKey: nsfont]; + Vfonts_in_cache = Fcons (font_object, Vfonts_in_cache); + } } font_info = (struct nsfont_info *) XFONT_OBJECT (font_object); @@ -1529,4 +1535,7 @@ syms_of_nsfont (void) doc: /* Internal use: maps font registry to Unicode script. */); ascii_printable = NULL; + + Vfonts_in_cache = Qnil; + staticpro (&Vfonts_in_cache); } -- 2.39.2