diff options
author | culler <culler> | 2020-07-27 16:27:47 (GMT) |
---|---|---|
committer | culler <culler> | 2020-07-27 16:27:47 (GMT) |
commit | 50092ff480b5a538c303cc781bf30505d4c2ba08 (patch) | |
tree | b02dbbf1709ef6db989d4c47fd3c8442513e1dd6 /generic | |
parent | ad4ba7d19aaf93762d9c0c3605c14a5aca7849a6 (diff) | |
parent | 916ea258d01119b9f5e02836ac8a92c4d6c4f520 (diff) | |
download | tk-50092ff480b5a538c303cc781bf30505d4c2ba08.zip tk-50092ff480b5a538c303cc781bf30505d4c2ba08.tar.gz tk-50092ff480b5a538c303cc781bf30505d4c2ba08.tar.bz2 |
Merge 8.6: fix testing and build issues on the various supported versions of macOS.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkTest.c | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/generic/tkTest.c b/generic/tkTest.c index 978d1c1..b104f13 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -78,6 +78,8 @@ typedef struct TImageInstance { TImageMaster *masterPtr; /* Pointer to master for image. */ XColor *fg; /* Foreground color for drawing in image. */ GC gc; /* Graphics context for drawing in image. */ + Bool displayFailed; /* macOS display attempted out of drawRect. */ + char buffer[200 + TCL_INTEGER_SPACE * 6]; /* message to log on display. */ } TImageInstance; /* @@ -1526,6 +1528,7 @@ ImageGet( instPtr->fg = Tk_GetColor(timPtr->interp, tkwin, "#ff0000"); gcValues.foreground = instPtr->fg->pixel; instPtr->gc = Tk_GetGC(tkwin, GCForeground, &gcValues); + instPtr->displayFailed = False; return instPtr; } @@ -1560,41 +1563,50 @@ ImageDisplay( * imageX and imageY. */ { TImageInstance *instPtr = (TImageInstance *)clientData; - char buffer[200 + TCL_INTEGER_SPACE * 6]; /* * The purpose of the test image type is to track the calls to an image - * display proc and record the parameters passed in each call. On macOS - * a display proc must be run inside of the drawRect method of an NSView - * in order for the graphics operations to have any effect. To deal with + * display proc and record the parameters passed in each call. On macOS a + * display proc must be run inside of the drawRect method of an NSView in + * order for the graphics operations to have any effect. To deal with * this, whenever a display proc is called outside of any drawRect method - * it schedules a redraw of the NSView by calling [view setNeedsDisplay:YES]. - * This will trigger a later call to the view's drawRect method which will - * run the display proc a second time. + * it schedules a redraw of the NSView. * - * This complicates testing, since it can result in more calls to the display - * proc than are expected by the test. It can also result in an inconsistent - * number of calls unless the test waits until the call to drawRect actually - * occurs before validating its results. - * - * In an attempt to work around this, this display proc only logs those - * calls which occur within a drawRect method. This means that tests must - * be written so as to ensure that the drawRect method is run before - * results are validated. In practice it usually suffices to run update - * idletasks (to run the display proc the first time) followed by update - * (to run the display proc in drawRect). - * - * This also has the consequence that the image changed command will log - * different results on Aqua than on other systems, because when the image - * is redisplayed in the drawRect method the entire image will be drawn, - * not just the changed portion. Tests must account for this. + * In an attempt to work around this, each image instance maintains it own + * copy of the log message which gets written on the first call to the + * display proc. This usually means that the message created on macOS is + * the same as that created on other platforms. However it is possible + * for the messages to differ for other reasons, namely differences in + * how damage regions are computed. */ if (LOG_DISPLAY(drawable)) { - sprintf(buffer, "%s display %d %d %d %d", - instPtr->masterPtr->imageName, imageX, imageY, width, height); + if (instPtr->displayFailed == False) { + + /* + * Drawing is possible on the first call to DisplayImage. + * Log the message. + */ + + sprintf(instPtr->buffer, "%s display %d %d %d %d", + instPtr->masterPtr->imageName, imageX, imageY, width, height); + } Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, - NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); + NULL, instPtr->buffer, + TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); + instPtr->displayFailed = False; + } else { + + /* + * Drawing is not possible on the first call to DisplayImage. + * Save the message, but do not log it until the actual display. + */ + + if (instPtr->displayFailed == False) { + sprintf(instPtr->buffer, "%s display %d %d %d %d", + instPtr->masterPtr->imageName, imageX, imageY, width, height); + } + instPtr->displayFailed = True; } if (width > (instPtr->masterPtr->width - imageX)) { width = instPtr->masterPtr->width - imageX; |