summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogelnew1@free.fr <fvogel>2016-05-30 18:36:48 (GMT)
committerfvogelnew1@free.fr <fvogel>2016-05-30 18:36:48 (GMT)
commit9289da7e333e253a42a70fe52decb64d30b7a8b1 (patch)
treec03f283d8eb1c4cf5ca30ce5f4859c92849c691b
parent31e88b9b54f3e935e18f053fdf6eed233db3166c (diff)
parent27dc84883dcb0433fcbecdd32205d7f7d93826fb (diff)
downloadtk-9289da7e333e253a42a70fe52decb64d30b7a8b1.zip
tk-9289da7e333e253a42a70fe52decb64d30b7a8b1.tar.gz
tk-9289da7e333e253a42a70fe52decb64d30b7a8b1.tar.bz2
Fixed [79549a9134] - Mouse pointer warping crashes
-rw-r--r--generic/tkBind.c13
-rw-r--r--tests/bind.test12
2 files changed, 23 insertions, 2 deletions
diff --git a/generic/tkBind.c b/generic/tkBind.c
index c75f6a0..8ee5994 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -3535,8 +3535,17 @@ 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. Also
+ * one needs to guard against window destruction in the meantime.
+ */
+
+ if (Tk_IsMapped(dispPtr->warpWindow)
+ && (Tk_WindowId(dispPtr->warpWindow) != None)) {
+ TkpWarpPointer(dispPtr);
+ XForceScreenSaver(dispPtr->display, ScreenSaverReset);
+ }
dispPtr->flags &= ~TK_DISPLAY_IN_WARP;
}
diff --git a/tests/bind.test b/tests/bind.test
index 0a4d114..9f0caa7 100644
--- a/tests/bind.test
+++ b/tests/bind.test
@@ -6157,6 +6157,18 @@ test bind-31.7 {virtual event user_data field - unshared, asynch} -setup {
destroy .t.f
} -result {{} {} {TestUserData >b<}}
+test bind-32 {-warp, window was destroyed before the idle callback DoWarp} -setup {
+ frame .t.f
+ pack .t.f
+ focus -force .t.f
+ update
+} -body {
+ event generate .t.f <Button-1> -warp 1
+ destroy .t.f
+ update ; # shall simply not crash
+} -cleanup {
+} -result {}
+
# cleanup
cleanupTests