From 6b354b74b09729ef0b336a4c1504ed66824a4d5a Mon Sep 17 00:00:00 2001
From: fvogel <fvogelnew1@free.fr>
Date: Sun, 14 Jan 2018 14:54:17 +0000
Subject: [PATCH 108/693] Fix [1821174fff] and [1938774fff]: RenderBadPicture
 (invalid Picture parameter) error returned on application exit when 'send'
 was renamed to {}. Patch from Christian Werner.

---
 unix/tkUnixRFont.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c
index d43ed2460..abdde7819 100644
--- a/unix/tkUnixRFont.c
+++ b/unix/tkUnixRFont.c
@@ -388,6 +388,16 @@ FinishedWithFont(
     if (fontPtr->fontset) {
 	FcFontSetDestroy(fontPtr->fontset);
     }
+
+    /*
+     * Synchronize with X server before dropping the error handler.
+     * This seems to catch sporadic RenderBadPicture errors on tear
+     * down of an application.
+     *
+     * See bugs [1821174fff] and [1938774fff].
+     */
+    XSync(fontPtr->display, False);
+
     Tk_DeleteErrorHandler(handler);
 }
 
-- 
2.19.1

