Suggested by Eli Zaretskii (Bug#20890#31).
* src/font.h (font_data_structures_may_be_ill_formed): New function.
* src/ftfont.c (ftfont_close):
* src/ftcrfont.c (ftcrfont_close): Use it.
font_deferred_log ((ACTION), (ARG), (RESULT)); \
} while (false)
+/* FIXME: This is for use in functions that can be called while
+ garbage-collecting, but which assume that Lisp data structures are
+ properly-formed. This invalid assumption can lead to core dumps
+ (Bug#20890). */
+INLINE bool
+font_data_structures_may_be_ill_formed (void)
+{
+#ifdef USE_CAIRO
+ /* Although this works around Bug#20890, it is probably not the
+ right thing to do. */
+ return gc_in_progress;
+#else
+ return false;
+#endif
+}
+
INLINE_HEADER_END
#endif /* not EMACS_FONT_H */
static void
ftcrfont_close (struct font *font)
{
+ if (font_data_structures_may_be_ill_formed ())
+ return;
+
struct ftcrfont_info *ftcrfont_info = (struct ftcrfont_info *) font;
int i;
void
ftfont_close (struct font *font)
{
- /* FIXME: Although this function can be called while garbage-collecting,
- the function assumes that Lisp data structures are properly-formed.
- This invalid assumption can lead to core dumps (Bug#20890). */
-#ifdef USE_CAIRO
- /* Although this works around Bug#20890, it is probably not the
- right thing to do. */
- if (gc_in_progress)
+ if (font_data_structures_may_be_ill_formed ())
return;
-#endif
struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
Lisp_Object val, cache;