Subject: Fixed [79549a9134] - Mouse pointer warping crashes

From: fvogel <[email-masked]>
Date: Thu, 26 May 2016 18:21:34 +0000

---
 generic/tkBind.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/generic/tkBind.c b/generic/tkBind.c
index 9cd3b7b..81c768b 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -3535,8 +3535,16 @@ DoWarp(
 {
     TkDisplay *dispPtr = clientData;
 
-    TkpWarpPointer(dispPtr);
-    XForceScreenSaver(dispPtr->display, ScreenSaverReset);
+    /*
+     * DoWarp was scheduled only if the window was mapped. It needs to be
+     * still mapped at the time the present idle callback is executed. In
+     * particular, this guards against window destruction in the meantime.
+     */
+
+    if (Tk_IsMapped(dispPtr->warpWindow)) {
+        TkpWarpPointer(dispPtr);
+        XForceScreenSaver(dispPtr->display, ScreenSaverReset);
+    }
     dispPtr->flags &= ~TK_DISPLAY_IN_WARP;
 }
 
-- 
cgit v0.12