aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Rudalics2015-06-16 15:09:24 +0200
committerMartin Rudalics2015-06-16 15:09:24 +0200
commit93ae9f46e7947aeb2180e3b8a98b551fa143ba51 (patch)
tree39aebf3eddb597848c0e7375598fa7eb58e55fea /src
parent32a488344057f210b51f4618feb3a85799eef0c5 (diff)
downloademacs-93ae9f46e7947aeb2180e3b8a98b551fa143ba51.tar.gz
emacs-93ae9f46e7947aeb2180e3b8a98b551fa143ba51.zip
Fix handling of image cache refcounts. (Bug#20802)
This backports Eli Zaretskii's solution of this problem for W32 to X and NS. * src/nsfns.m (image_cache_refcount): Define unconditionally. (unwind_create_frame): If the image cache's reference count hasn't been updated yet, do that now. (Fx_create_frame): Set image_cache_refcount unconditionally. * src/xfns.c (image_cache_refcount): Define unconditionally. (unwind_create_frame): If the image cache's reference count hasn't been updated yet, do that now. (Fx_create_frame, x_create_tip_frame): Set image_cache_refcount unconditionally. * src/w32fns.c (image_cache_refcount): Make it a ptrdiff_t as on X and NS.
Diffstat (limited to 'src')
-rw-r--r--src/nsfns.m15
-rw-r--r--src/w32fns.c3
-rw-r--r--src/xfns.c17
3 files changed, 27 insertions, 8 deletions
diff --git a/src/nsfns.m b/src/nsfns.m
index 6a2e2ff14a4..286445c0030 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -70,9 +70,7 @@ Lisp_Object Fx_open_connection (Lisp_Object, Lisp_Object, Lisp_Object);
70static Lisp_Object as_script, *as_result; 70static Lisp_Object as_script, *as_result;
71static int as_status; 71static int as_status;
72 72
73#ifdef GLYPH_DEBUG
74static ptrdiff_t image_cache_refcount; 73static ptrdiff_t image_cache_refcount;
75#endif
76 74
77 75
78/* ========================================================================== 76/* ==========================================================================
@@ -1005,6 +1003,17 @@ unwind_create_frame (Lisp_Object frame)
1005 struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); 1003 struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
1006#endif 1004#endif
1007 1005
1006 /* If the frame's image cache refcount is still the same as our
1007 private shadow variable, it means we are unwinding a frame
1008 for which we didn't yet call init_frame_faces, where the
1009 refcount is incremented. Therefore, we increment it here, so
1010 that free_frame_faces, called in x_free_frame_resources
1011 below, will not mistakenly decrement the counter that was not
1012 incremented yet to account for this new frame. */
1013 if (FRAME_IMAGE_CACHE (f) != NULL
1014 && FRAME_IMAGE_CACHE (f)->refcount == image_cache_refcount)
1015 FRAME_IMAGE_CACHE (f)->refcount++;
1016
1008 x_free_frame_resources (f); 1017 x_free_frame_resources (f);
1009 free_glyphs (f); 1018 free_glyphs (f);
1010 1019
@@ -1241,10 +1250,8 @@ This function is an internal primitive--use `make-frame' instead. */)
1241 x_default_parameter (f, parms, Qright_fringe, Qnil, 1250 x_default_parameter (f, parms, Qright_fringe, Qnil,
1242 "rightFringe", "RightFringe", RES_TYPE_NUMBER); 1251 "rightFringe", "RightFringe", RES_TYPE_NUMBER);
1243 1252
1244#ifdef GLYPH_DEBUG
1245 image_cache_refcount = 1253 image_cache_refcount =
1246 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0; 1254 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
1247#endif
1248 1255
1249 init_frame_faces (f); 1256 init_frame_faces (f);
1250 1257
diff --git a/src/w32fns.c b/src/w32fns.c
index c247a9b3b3a..5f40729011e 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -204,7 +204,8 @@ unsigned int msh_mousewheel = 0;
204static unsigned menu_free_timer = 0; 204static unsigned menu_free_timer = 0;
205 205
206#ifdef GLYPH_DEBUG 206#ifdef GLYPH_DEBUG
207static int image_cache_refcount, dpyinfo_refcount; 207static ptrdiff_t image_cache_refcount;
208static int dpyinfo_refcount;
208#endif 209#endif
209 210
210static HWND w32_visible_system_caret_hwnd; 211static HWND w32_visible_system_caret_hwnd;
diff --git a/src/xfns.c b/src/xfns.c
index 634881d0a66..d066043ae5e 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -120,8 +120,8 @@ extern LWLIB_ID widget_id_tick;
120 120
121#define MAXREQUEST(dpy) (XMaxRequestSize (dpy)) 121#define MAXREQUEST(dpy) (XMaxRequestSize (dpy))
122 122
123#ifdef GLYPH_DEBUG
124static ptrdiff_t image_cache_refcount; 123static ptrdiff_t image_cache_refcount;
124#ifdef GLYPH_DEBUG
125static int dpyinfo_refcount; 125static int dpyinfo_refcount;
126#endif 126#endif
127 127
@@ -2828,6 +2828,17 @@ unwind_create_frame (Lisp_Object frame)
2828 struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); 2828 struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
2829#endif 2829#endif
2830 2830
2831 /* If the frame's image cache refcount is still the same as our
2832 private shadow variable, it means we are unwinding a frame
2833 for which we didn't yet call init_frame_faces, where the
2834 refcount is incremented. Therefore, we increment it here, so
2835 that free_frame_faces, called in x_free_frame_resources
2836 below, will not mistakenly decrement the counter that was not
2837 incremented yet to account for this new frame. */
2838 if (FRAME_IMAGE_CACHE (f) != NULL
2839 && FRAME_IMAGE_CACHE (f)->refcount == image_cache_refcount)
2840 FRAME_IMAGE_CACHE (f)->refcount++;
2841
2831 x_free_frame_resources (f); 2842 x_free_frame_resources (f);
2832 free_glyphs (f); 2843 free_glyphs (f);
2833 2844
@@ -3205,9 +3216,9 @@ This function is an internal primitive--use `make-frame' instead. */)
3205 "scrollBarBackground", 3216 "scrollBarBackground",
3206 "ScrollBarBackground", false); 3217 "ScrollBarBackground", false);
3207 3218
3208#ifdef GLYPH_DEBUG
3209 image_cache_refcount = 3219 image_cache_refcount =
3210 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0; 3220 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
3221#ifdef GLYPH_DEBUG
3211 dpyinfo_refcount = dpyinfo->reference_count; 3222 dpyinfo_refcount = dpyinfo->reference_count;
3212#endif /* GLYPH_DEBUG */ 3223#endif /* GLYPH_DEBUG */
3213 3224
@@ -5178,9 +5189,9 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
5178 x_default_parameter (f, parms, Qborder_color, build_string ("black"), 5189 x_default_parameter (f, parms, Qborder_color, build_string ("black"),
5179 "borderColor", "BorderColor", RES_TYPE_STRING); 5190 "borderColor", "BorderColor", RES_TYPE_STRING);
5180 5191
5181#ifdef GLYPH_DEBUG
5182 image_cache_refcount = 5192 image_cache_refcount =
5183 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0; 5193 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
5194#ifdef GLYPH_DEBUG
5184 dpyinfo_refcount = dpyinfo->reference_count; 5195 dpyinfo_refcount = dpyinfo->reference_count;
5185#endif /* GLYPH_DEBUG */ 5196#endif /* GLYPH_DEBUG */
5186 5197