summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorculler <culler>2019-10-11 20:14:40 (GMT)
committerculler <culler>2019-10-11 20:14:40 (GMT)
commit09bb06b273610a411d611b606b08cb6b6b30eec7 (patch)
treec343ed5a57457d05a7017d6147c9933dd012b21b
parent624d527a6a5bb7228d19aa80b8307151c47c2692 (diff)
downloadtk-09bb06b273610a411d611b606b08cb6b6b30eec7.zip
tk-09bb06b273610a411d611b606b08cb6b6b30eec7.tar.gz
tk-09bb06b273610a411d611b606b08cb6b6b30eec7.tar.bz2
Use vwait instead of after in canvImg.test. On macOS protect against exceptions
when periodic events are scheduled.
-rw-r--r--macosx/tkMacOSXMouseEvent.c2
-rw-r--r--macosx/tkMacOSXNotify.c9
-rw-r--r--tests/canvImg.test20
3 files changed, 17 insertions, 14 deletions
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index 074e36e..bc7c616 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -58,6 +58,7 @@ enum {
NSTrackingArea *trackingArea = nil;
NSInteger eventNumber, clickCount, buttonNumber;
#endif
+ [NSEvent stopPeriodicEvents];
#ifdef TK_MAC_DEBUG_EVENTS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
@@ -656,6 +657,7 @@ TkpSetCapture(
while (winPtr && !Tk_IsTopLevel(winPtr)) {
winPtr = winPtr->parentPtr;
}
+ [NSEvent stopPeriodicEvents];
captureWinPtr = (Tk_Window) winPtr;
}
diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c
index a4a87c6..afee942 100644
--- a/macosx/tkMacOSXNotify.c
+++ b/macosx/tkMacOSXNotify.c
@@ -311,17 +311,16 @@ TkMacOSXEventsSetupProc(
if (currentEvent) {
if (currentEvent.type > 0) {
Tcl_SetMaxBlockTime(&zeroBlockTime);
- if (havePeriodicEvents) {
- [NSEvent stopPeriodicEvents];
- havePeriodicEvents = NO;
- }
+ [NSEvent stopPeriodicEvents];
+ havePeriodicEvents = NO;
}
} else if (!havePeriodicEvents){
/*
* When the user is not generating events we schedule a "hearbeat"
* event to fire every 0.1 seconds. This helps to make the vwait
- * command more responsive when there is no user input.
+ * command more responsive when there is no user input, e.g. when
+ * running the test suite.
*/
havePeriodicEvents = YES;
diff --git a/tests/canvImg.test b/tests/canvImg.test
index aa6781d..ea4aa3a 100644
--- a/tests/canvImg.test
+++ b/tests/canvImg.test
@@ -166,12 +166,12 @@ test canvImg-4.2 {ConfigureImage procedure} -constraints testImageType -setup {
update
set x {}
set y {}
- set timer [after 300 {lappend y "timeout"}]
+ set timer [after 300 {lappend y "timed out"}]
.c itemconfigure i1 -image foo2
update idletasks
update
# On MacOS we need to wait for the test image display procedure to run.
- while {"timeout" ni $y && [lindex $y end 1] ne "display"} {
+ while {"timed out" ni $y && [lindex $y end 1] ne "display"} {
vwait y
}
after cancel timer
@@ -741,9 +741,10 @@ test canvImg-10.1 {TranslateImage procedure} -constraints testImageType -setup {
.c create image 50 100 -image foo -tags image -anchor nw
update
set x {}
+ set timer [after 500 {lappend x "timed out"}]
foo changed 2 4 6 8 30 15
- # macOS Catalina needs a delay here.
- after 20
+ vwait x
+ after cancel $timer
update
return $x
} -cleanup {
@@ -759,9 +760,10 @@ test canvImg-11.1 {TranslateImage procedure} -constraints testImageType -setup {
.c create image 50 100 -image foo -tags image -anchor nw
update
set x {}
+ set timer [after 500 {lappend x "timed out"}]
foo changed 2 4 6 8 40 50
- # macOS Catalina needs a delay here.
- after 20
+ vwait x
+ after cancel $timer
update
return $x
} -cleanup {
@@ -799,14 +801,14 @@ test canvImg-11.3 {ImageChangedProc procedure} -constraints {
image create test foo2 -variable y
foo changed 0 0 0 0 40 50
foo2 changed 0 0 0 0 80 60
-
.c create image 50 100 -image foo -tags image -anchor nw
.c create image 70 110 -image foo2 -anchor nw
update
set y {}
+ set timer [after 500 {lappend y "timed out"}]
image create test foo -variable x
- # macOS Catalina needs a delay here.
- after 20
+ vwait x
+ after cancel $timer
update
return $y
} -cleanup {