From f7340ee2b50ac7966dc4f3625ba615529d30c8f9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 11 Jul 2024 21:44:57 +0000 Subject: [PATCH 01/17] Fix [5f739d2253] for borderwidth (canvas), width and height (buttons) --- generic/tkButton.c | 19 ++++++++++++++++++- generic/tkCanvas.c | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/generic/tkButton.c b/generic/tkButton.c index 9d033e46e..2dd2736a6 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -1315,7 +1315,24 @@ ConfigureButton( Tk_FreeSavedOptions(&savedOptions); } - /* + if (butPtr->width < 0) { + butPtr->width = 0; + if (butPtr->widthPtr) { + Tcl_DecrRefCount(butPtr->widthPtr); + } + butPtr->widthPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(butPtr->widthPtr); + } + if (butPtr->height < 0) { + butPtr->height = 0; + if (butPtr->heightPtr) { + Tcl_DecrRefCount(butPtr->heightPtr); + } + butPtr->heightPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(butPtr->heightPtr); + } + + /* * Reestablish the variable traces, if they're needed. */ diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 879cf2792..a65bcbb6f 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -2276,6 +2276,9 @@ ConfigureCanvas( if (canvasPtr->highlightWidth < 0) { canvasPtr->highlightWidth = 0; } + if (canvasPtr->borderWidth < 0) { + canvasPtr->borderWidth = 0; + } canvasPtr->inset = canvasPtr->borderWidth + canvasPtr->highlightWidth; gcValues.function = GXcopy; From 2824aed85ced65cab273b9c14d7fa65a9e423fae Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 12 Jul 2024 06:34:04 +0000 Subject: [PATCH 02/17] handle -borderwidth and -spacing[123] for text tags --- doc/SetOptions.3 | 2 +- generic/tkTextTag.c | 28 +++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/doc/SetOptions.3 b/doc/SetOptions.3 index cc206d49f..ede76d15c 100644 --- a/doc/SetOptions.3 +++ b/doc/SetOptions.3 @@ -530,7 +530,7 @@ free, and restore saved copies of the type and creating a structure pointing to those procedures: .CS typedef struct { - char *name; + const char *name; Tk_CustomOptionSetProc *\fIsetProc\fR; Tk_CustomOptionGetProc *\fIgetProc\fR; Tk_CustomOptionRestoreProc *\fIrestoreProc\fR; diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index a41caa41a..fff5a5a99 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -363,22 +363,40 @@ TkTextTagCmd( * from "unspecified"). */ - if (tagPtr->borderWidth < 0) { - tagPtr->borderWidth = 0; + if (tagPtr->borderWidth != INT_MIN) { + if (tagPtr->borderWidth < 0) { + tagPtr->borderWidth = INT_MIN; + if (tagPtr->borderWidthPtr) { + Tcl_DecrRefCount(tagPtr->borderWidthPtr); + tagPtr->borderWidthPtr = NULL; + } + } } if (tagPtr->spacing1 != INT_MIN) { if (tagPtr->spacing1 < 0) { - tagPtr->spacing1 = 0; + tagPtr->spacing1 = INT_MIN; + if (tagPtr->spacing1Obj) { + Tcl_DecrRefCount(tagPtr->spacing1Obj); + tagPtr->spacing1Obj = NULL; + } } } if (tagPtr->spacing2 != INT_MIN) { if (tagPtr->spacing2 < 0) { - tagPtr->spacing2 = 0; + tagPtr->spacing2 = INT_MIN; + if (tagPtr->spacing2Obj) { + Tcl_DecrRefCount(tagPtr->spacing2Obj); + tagPtr->spacing2Obj = NULL; + } } } if (tagPtr->spacing3 != INT_MIN) { if (tagPtr->spacing3 < 0) { - tagPtr->spacing3 = 0; + tagPtr->spacing3 = INT_MIN; + if (tagPtr->spacing3Obj) { + Tcl_DecrRefCount(tagPtr->spacing3Obj); + tagPtr->spacing3Obj = NULL; + } } } if (tagPtr->tabArrayPtr != NULL) { From df6780a5bbe54cac2a911cd4070556d3a2f76c11 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 10 Dec 2024 15:29:46 +0000 Subject: [PATCH 03/17] progress in "text" widget --- generic/tkText.c | 14 +++++++++++++- generic/tkTextImage.c | 14 ++++++++++++++ generic/tkTextTag.c | 39 +++++++++++++++++++++++++++++++-------- generic/tkTextWind.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 9 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 20bebf7cb..37fcbb2c1 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2064,7 +2064,7 @@ ConfigureText( int oldExport = (textPtr->exportSelection) && (!Tcl_IsSafe(textPtr->interp)); int mask = 0; int selBorderWidth = INT_MIN, spacing1, spacing2, spacing3; - int insertBorderWidth, insertWidth; + int insertBorderWidth, insertWidth, padX, padY; if (Tk_SetOptions(interp, (char *) textPtr, textPtr->optionTable, objc, objv, textPtr->tkwin, &savedOptions, &mask) != TCL_OK) { @@ -2204,6 +2204,18 @@ ConfigureText( * Don't allow negative spacings. */ + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->padXObj, &padX); + if (padX < 0) { + Tcl_DecrRefCount(textPtr->padXObj); + textPtr->padXObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->padXObj); + } + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->padYObj, &padY); + if (padY < 0) { + Tcl_DecrRefCount(textPtr->padYObj); + textPtr->padYObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->padYObj); + } Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->spacing1Obj, &spacing1); if (spacing1 < 0) { spacing1 = 0; diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c index b2efec829..b9d6787f7 100644 --- a/generic/tkTextImage.c +++ b/generic/tkTextImage.c @@ -539,9 +539,23 @@ EmbImageLayoutProc( if (eiPtr->body.ei.padXObj) { Tk_GetPixelsFromObj(NULL, textPtr->tkwin, eiPtr->body.ei.padXObj, &padX); + if (padX < 0) { + if (eiPtr->body.ei.padXObj) { + Tcl_DecrRefCount(eiPtr->body.ei.padXObj); + } + eiPtr->body.ei.padXObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(eiPtr->body.ei.padXObj); + } } if (eiPtr->body.ei.padYObj) { Tk_GetPixelsFromObj(NULL, textPtr->tkwin, eiPtr->body.ei.padYObj, &padY); + if (padY < 0) { + if (eiPtr->body.ei.padYObj) { + Tcl_DecrRefCount(eiPtr->body.ei.padYObj); + } + eiPtr->body.ei.padYObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(eiPtr->body.ei.padYObj); + } } /* * See if there's room for this image on this line. diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 6f12c1e28..1e8d421f0 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -369,8 +369,34 @@ TkTextTagCmd( if (borderWidth < 0) { borderWidth = 0; Tcl_DecrRefCount(tagPtr->borderWidthObj); - tagPtr->borderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(tagPtr->borderWidthObj); + tagPtr->borderWidthObj = NULL; + } + } + if (tagPtr->lMargin1Obj) { + int lMargin1; + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, tagPtr->lMargin1Obj, &lMargin1); + if (lMargin1 < 0) { + lMargin1 = 0; + Tcl_DecrRefCount(tagPtr->lMargin1Obj); + tagPtr->lMargin1Obj = NULL; + } + } + if (tagPtr->lMargin2Obj) { + int lMargin2; + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, tagPtr->lMargin2Obj, &lMargin2); + if (lMargin2 < 0) { + lMargin2 = 0; + Tcl_DecrRefCount(tagPtr->lMargin2Obj); + tagPtr->lMargin2Obj = NULL; + } + } + if (tagPtr->rMarginObj) { + int rMargin; + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, tagPtr->rMarginObj, &rMargin); + if (rMargin < 0) { + rMargin = 0; + Tcl_DecrRefCount(tagPtr->rMarginObj); + tagPtr->rMarginObj = NULL; } } if (tagPtr->spacing1Obj) { @@ -379,8 +405,7 @@ TkTextTagCmd( if (spacing1 < 0) { spacing1 = 0; Tcl_DecrRefCount(tagPtr->spacing1Obj); - tagPtr->spacing1Obj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(tagPtr->spacing1Obj); + tagPtr->spacing1Obj = NULL; } } if (tagPtr->spacing2Obj) { @@ -389,8 +414,7 @@ TkTextTagCmd( if (spacing2 < 0) { spacing2 = 0; Tcl_DecrRefCount(tagPtr->spacing2Obj); - tagPtr->spacing2Obj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(tagPtr->spacing2Obj); + tagPtr->spacing2Obj = NULL; } } if (tagPtr->spacing3Obj) { @@ -399,8 +423,7 @@ TkTextTagCmd( if (spacing3 < 0) { spacing3 = 0; Tcl_DecrRefCount(tagPtr->spacing3Obj); - tagPtr->spacing3Obj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(tagPtr->spacing3Obj); + tagPtr->spacing3Obj = NULL; } } if (tagPtr->tabArrayPtr != NULL) { diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c index d33687764..809cdfacd 100644 --- a/generic/tkTextWind.c +++ b/generic/tkTextWind.c @@ -991,9 +991,23 @@ EmbWinLayoutProc( } else { if (ewPtr->body.ew.padXObj) { Tk_GetPixelsFromObj(NULL, textPtr->tkwin, ewPtr->body.ew.padXObj, &padX); + if (padX < 0) { + if (ewPtr->body.ew.padXObj) { + Tcl_DecrRefCount(ewPtr->body.ew.padXObj); + } + ewPtr->body.ew.padXObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(ewPtr->body.ew.padXObj); + } } if (ewPtr->body.ew.padYObj) { Tk_GetPixelsFromObj(NULL, textPtr->tkwin, ewPtr->body.ew.padYObj, &padY); + if (padY < 0) { + if (ewPtr->body.ew.padYObj) { + Tcl_DecrRefCount(ewPtr->body.ew.padYObj); + } + ewPtr->body.ew.padYObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(ewPtr->body.ew.padYObj); + } } width = Tk_ReqWidth(ewPtr->body.ew.tkwin) + 2 * padX; height = Tk_ReqHeight(ewPtr->body.ew.tkwin) + 2 * padY; @@ -1261,9 +1275,23 @@ EmbWinBboxProc( } if (ewPtr->body.ew.padXObj) { Tk_GetPixelsFromObj(NULL, textPtr->tkwin, ewPtr->body.ew.padXObj, &padX); + if (padX < 0) { + if (ewPtr->body.ew.padXObj) { + Tcl_DecrRefCount(ewPtr->body.ew.padXObj); + } + ewPtr->body.ew.padXObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(ewPtr->body.ew.padXObj); + } } if (ewPtr->body.ew.padYObj) { Tk_GetPixelsFromObj(NULL, textPtr->tkwin, ewPtr->body.ew.padYObj, &padY); + if (padY < 0) { + if (ewPtr->body.ew.padYObj) { + Tcl_DecrRefCount(ewPtr->body.ew.padYObj); + } + ewPtr->body.ew.padYObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(ewPtr->body.ew.padYObj); + } } *xPtr = chunkPtr->x + padX; if (ewPtr->body.ew.stretch) { From 2cbe082194ca50d4f0b3d44cd9f9582556c5fd11 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 19 Jan 2025 22:17:26 +0000 Subject: [PATCH 04/17] (cherry-pick): Rename the fallback proc menubarheight to testmenubarheight --- tests/constraints.tcl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/constraints.tcl b/tests/constraints.tcl index bec532e37..ae1c66cd2 100644 --- a/tests/constraints.tcl +++ b/tests/constraints.tcl @@ -255,21 +255,21 @@ namespace eval tk { # got moved to the requested location should use a y coordinate larger than the # height of the menubar (normally 23 pixels) and an x coordinate larger than the # width of the dock, if it happens to be on the left. - # menubarheight deals with this issue but may not be available from the test + # testmenubarheight deals with this issue but may not be available from the test # environment, therefore provide a fallback here - if {[llength [info procs menubarheight]] == 0} { + if {[llength [info procs testmenubarheight]] == 0} { if {[tk windowingsystem] ne "aqua"} { # Windows may overlap the menubar - proc menubarheight {} { + proc testmenubarheight {} { return 0 } } else { # Windows may not overlap the menubar - proc menubarheight {} { + proc testmenubarheight {} { return 30 ; # arbitrary value known to be larger than the menubar height } } - namespace export menubarheight + namespace export testmenubarheight } } } From 04fb6e0362d812d7a0e12c7cd28ff2be0616db88 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 21 Jan 2025 15:47:26 +0000 Subject: [PATCH 05/17] Fix [080a28104e]: crash caused by nil UTType when user provides a bogus file type. --- macosx/tkMacOSXDialog.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index b9ceaff4b..2ab603d90 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -37,7 +37,9 @@ static void setAllowedFileTypes( NSMutableArray *allowedTypes = [NSMutableArray array]; for (NSString *ext in extensions) { UTType *uttype = [UTType typeWithFilenameExtension: ext]; - [allowedTypes addObject:uttype]; + if (uttype) { + [allowedTypes addObject:uttype]; + } } [panel setAllowedContentTypes:allowedTypes]; } else { From 625d14f56acd0760733b4df44216313e80f88dfc Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 22 Jan 2025 02:52:55 +0000 Subject: [PATCH 06/17] Add a non-regression test, which turns out to require considerable extra machinery. --- macosx/tkMacOSXDialog.c | 50 +++++++++++++++++++++++++++++++++++++++- macosx/tkMacOSXInit.c | 7 ++++++ macosx/tkMacOSXPrivate.h | 6 +++++ macosx/tkMacOSXTest.c | 7 +++++- tests/filebox.test | 8 +++++++ 5 files changed, 76 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 2ab603d90..672e26381 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -87,6 +87,41 @@ static filepanelFilterInfo filterInfo; static NSOpenPanel *openpanel; static NSSavePanel *savepanel; +/* + * A thread which closes the currently running modal dialog after a timeout. + */ + +@interface TKPanelMonitor: NSThread { +@private + NSTimeInterval _timeout; +} + +- (id) initWithTimeout: (NSTimeInterval) timeout; + +@end + +@implementation TKPanelMonitor: NSThread + +- (id) initWithTimeout: (NSTimeInterval) timeout { + self = [super init]; + if (self) { + _timeout = timeout; + return self; + } + return self; +} + +- (void) main +{ + [NSThread sleepForTimeInterval:_timeout]; + if ([self isCancelled]) { + [NSThread exit]; + } + [NSApp stopModalWithCode:modalCancel]; +} +@end + + static const char *const colorOptionStrings[] = { "-initialcolor", "-parent", "-title", NULL }; @@ -870,7 +905,20 @@ Tk_GetOpenFileObjCmd( parent = nil; parentIsKey = False; } - modalReturnCode = showOpenSavePanel(openpanel, parent, interp, cmdObj, multiple); + TKPanelMonitor *monitor; + if (testsAreRunning) { + /* + * We need the panel to close by itself when running tests. + */ + + monitor = [[TKPanelMonitor alloc] initWithTimeout: 1.0]; + [monitor start]; + } + modalReturnCode = showOpenSavePanel(openpanel, parent, interp, cmdObj, + multiple); + if (testsAreRunning) { + [monitor cancel]; + } if (cmdObj) { Tcl_DecrRefCount(cmdObj); } diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 7d7a690a9..1a42ab842 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -21,6 +21,12 @@ #include #include +/* + * This flag is set if tests are being run. + */ + +int testsAreRunning = 0; + static char tkLibPath[PATH_MAX + 1] = ""; /* @@ -45,6 +51,7 @@ static Tcl_ObjCmdProc TkMacOSVersionObjCmd; @synthesize tkLiveResizeEnded = _tkLiveResizeEnded; @synthesize tkWillExit = _tkWillExit; @synthesize tkPointerWindow = _tkPointerWindow; +; - (void) setTkPointerWindow: (TkWindow *)winPtr { if (winPtr) { diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 368f35ba5..e2a52d3e0 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -134,6 +134,12 @@ STRINGIFY(symbol)); \ } +/* + * This is set to 1 if tests are being run. Defined in tkMacOSXInit.c. + */ + +extern int testsAreRunning; + /* * The structure of a 32-bit XEvent keycode on macOS. It may be viewed as * an unsigned int or as having either two or three bitfields. diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index 544707228..185c4a81a 100644 --- a/macosx/tkMacOSXTest.c +++ b/macosx/tkMacOSXTest.c @@ -16,7 +16,6 @@ #include "tkMacOSXConstants.h" #include "tkMacOSXWm.h" - /* * Forward declarations of procedures defined later in this file: */ @@ -48,6 +47,12 @@ int TkplatformtestInit( Tcl_Interp *interp) /* Interpreter to add commands to. */ { + /* + * Set a flag indicating that testing is in progress. + */ + + testsAreRunning = 1; + /* * Add commands for platform specific tests on MacOS here. */ diff --git a/tests/filebox.test b/tests/filebox.test index 2a02fbee6..eb5114aec 100644 --- a/tests/filebox.test +++ b/tests/filebox.test @@ -23,6 +23,14 @@ test fileDialog-0.2 {GetFileName: file types: MakeFilter() fails} { regsub -all "\0" $msg {\\0} msg list $x $msg } {1 {bad Macintosh file type "\0\0"}} +test fileDialog-0.3 {GetFileName: file types: bad filetype} { + # Check for the crash reported in ticket 080a28104. + + set filename [tk_getOpenFile -filetypes { + {"Invalid extension" {x.y}} + {"All files" {*}} + }] +} {} set tk_strictMotif_old $tk_strictMotif From 982ec19fb7dbd275b9046198dbb5a9514068f267 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 22 Jan 2025 13:51:28 +0000 Subject: [PATCH 07/17] Schedule a CI run --- .github/workflows/linux-with-tcl91-build.yml | 1 + .github/workflows/mac-build.yml | 1 + .github/workflows/win-build.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/linux-with-tcl91-build.yml b/.github/workflows/linux-with-tcl91-build.yml index 130198397..c03ce3109 100644 --- a/.github/workflows/linux-with-tcl91-build.yml +++ b/.github/workflows/linux-with-tcl91-build.yml @@ -5,6 +5,7 @@ on: - "main" - "core-8-branch" - "core-8-6-branch" + - "bug-080a28104e" tags: - "core-**" permissions: diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index 2e14ab69e..053326e64 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -5,6 +5,7 @@ on: - "main" - "core-8-branch" - "core-8-6-branch" + - "bug-080a28104e" tags: - "core-**" permissions: diff --git a/.github/workflows/win-build.yml b/.github/workflows/win-build.yml index 8e902566a..0ec997779 100644 --- a/.github/workflows/win-build.yml +++ b/.github/workflows/win-build.yml @@ -5,6 +5,7 @@ on: - "main" - "core-8-branch" - "core-8-6-branch" + - "bug-080a28104e" tags: - "core-**" permissions: From 5c13e9cd5844eed1f49799a128fcd2bc7ccb582f Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 22 Jan 2025 14:42:12 +0000 Subject: [PATCH 08/17] Remove extraneous semi-colon. --- macosx/tkMacOSXInit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 1a42ab842..3d0bad485 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -51,7 +51,7 @@ static Tcl_ObjCmdProc TkMacOSVersionObjCmd; @synthesize tkLiveResizeEnded = _tkLiveResizeEnded; @synthesize tkWillExit = _tkWillExit; @synthesize tkPointerWindow = _tkPointerWindow; -; + - (void) setTkPointerWindow: (TkWindow *)winPtr { if (winPtr) { From dd5ca5fe722e66df5d7f440aa77a9315b28cfbdc Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 23 Jan 2025 16:21:15 +0000 Subject: [PATCH 09/17] Only run the new test on Aqua. It hangs on XQuartz. --- tests/filebox.test | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/filebox.test b/tests/filebox.test index eb5114aec..e21c8e44f 100644 --- a/tests/filebox.test +++ b/tests/filebox.test @@ -23,14 +23,16 @@ test fileDialog-0.2 {GetFileName: file types: MakeFilter() fails} { regsub -all "\0" $msg {\\0} msg list $x $msg } {1 {bad Macintosh file type "\0\0"}} -test fileDialog-0.3 {GetFileName: file types: bad filetype} { - # Check for the crash reported in ticket 080a28104. +test fileDialog-0.3 {GetFileName: file types: bad filetype} \ +-constraints {[tk windowingsystem] eq "aqua"} \ +-body { + # Check for the Aqua crash reported in ticket 080a28104. set filename [tk_getOpenFile -filetypes { {"Invalid extension" {x.y}} {"All files" {*}} }] -} {} +} -result {} set tk_strictMotif_old $tk_strictMotif From 87d8e777c7d2a52ef5e9a00b249cc8a863ebef72 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 24 Jan 2025 14:36:04 +0000 Subject: [PATCH 10/17] Finish for "text". Alphabetise button and frame range checks --- generic/tkButton.c | 28 ++++++++--------- generic/tkFrame.c | 22 +++++++------- generic/tkText.c | 76 +++++++++++++++++++++++++++++----------------- 3 files changed, 73 insertions(+), 53 deletions(-) diff --git a/generic/tkButton.c b/generic/tkButton.c index 504f768a0..30a331339 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -1028,7 +1028,7 @@ ConfigureButton( int error, haveImage; Tk_Image image; int wrapLength, borderWidth, highlightWidth, padX, padY; - int butPtrWidth, butPtrHeight; + int width, height; /* * Eliminate any existing trace on variables monitored by the button. @@ -1092,13 +1092,6 @@ ConfigureButton( } else { Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->normalBorder); } - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->wrapLengthObj, &wrapLength); - if (wrapLength < 0) { - wrapLength = 0; - Tcl_DecrRefCount(butPtr->wrapLengthObj); - butPtr->wrapLengthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(butPtr->wrapLengthObj); - } Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthObj, &borderWidth); if (borderWidth < 0) { borderWidth = 0; @@ -1127,6 +1120,13 @@ ConfigureButton( butPtr->padYObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(butPtr->padYObj); } + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->wrapLengthObj, &wrapLength); + if (wrapLength < 0) { + wrapLength = 0; + Tcl_DecrRefCount(butPtr->wrapLengthObj); + butPtr->wrapLengthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(butPtr->wrapLengthObj); + } if (butPtr->type >= TYPE_CHECK_BUTTON) { Tcl_Obj *valuePtr, *namePtr; @@ -1274,13 +1274,13 @@ ConfigureButton( */ if (Tk_GetPixelsFromObj(interp, butPtr->tkwin, butPtr->widthObj, - &butPtrWidth) != TCL_OK) { + &width) != TCL_OK) { widthError: Tcl_AddErrorInfo(interp, "\n (processing \"-width\" option)"); continue; } if (Tk_GetPixelsFromObj(interp, butPtr->tkwin, butPtr->heightObj, - &butPtrHeight) != TCL_OK) { + &height) != TCL_OK) { heightError: Tcl_AddErrorInfo(interp, "\n (processing \"-height\" option)"); continue; @@ -1290,21 +1290,21 @@ ConfigureButton( * The button displays an ordinary text string. */ - if (Tcl_GetIntFromObj(interp, butPtr->widthObj, &butPtrWidth) + if (Tcl_GetIntFromObj(interp, butPtr->widthObj, &width) != TCL_OK) { goto widthError; } - if (Tcl_GetIntFromObj(interp, butPtr->heightObj, &butPtrHeight) + if (Tcl_GetIntFromObj(interp, butPtr->heightObj, &height) != TCL_OK) { goto heightError; } } - if (butPtrWidth < 0) { + if (width < 0) { Tcl_DecrRefCount(butPtr->widthObj); butPtr->widthObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(butPtr->widthObj); } - if (butPtrHeight < 0) { + if (height < 0) { Tcl_DecrRefCount(butPtr->heightObj); butPtr->heightObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(butPtr->heightObj); diff --git a/generic/tkFrame.c b/generic/tkFrame.c index 01c7075dc..03beec019 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -986,11 +986,11 @@ ConfigureFrame( Tk_SetWindowBackgroundPixmap(framePtr->tkwin, None); } - Tk_GetPixelsFromObj(NULL, framePtr->tkwin, framePtr->widthObj, &width); - if (width < 0) { - Tcl_DecrRefCount(framePtr->widthObj); - framePtr->widthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(framePtr->widthObj); + Tk_GetPixelsFromObj(NULL, framePtr->tkwin, framePtr->borderWidthObj, &borderWidth); + if (borderWidth < 0) { + Tcl_DecrRefCount(framePtr->borderWidthObj); + framePtr->borderWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(framePtr->borderWidthObj); } Tk_GetPixelsFromObj(NULL, framePtr->tkwin, framePtr->heightObj, &height); if (height < 0) { @@ -998,12 +998,6 @@ ConfigureFrame( framePtr->heightObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(framePtr->heightObj); } - Tk_GetPixelsFromObj(NULL, framePtr->tkwin, framePtr->borderWidthObj, &borderWidth); - if (borderWidth < 0) { - Tcl_DecrRefCount(framePtr->borderWidthObj); - framePtr->borderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(framePtr->borderWidthObj); - } Tk_GetPixelsFromObj(NULL, framePtr->tkwin, framePtr->highlightWidthObj, &highlightWidth); if (highlightWidth < 0) { Tcl_DecrRefCount(framePtr->highlightWidthObj); @@ -1022,6 +1016,12 @@ ConfigureFrame( framePtr->padYObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(framePtr->padYObj); } + Tk_GetPixelsFromObj(NULL, framePtr->tkwin, framePtr->widthObj, &width); + if (width < 0) { + Tcl_DecrRefCount(framePtr->widthObj); + framePtr->widthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(framePtr->widthObj); + } /* * If a -labelwidget is specified, check that it is valid and set up diff --git a/generic/tkText.c b/generic/tkText.c index 37fcbb2c1..0560610a0 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -2062,8 +2062,8 @@ ConfigureText( { Tk_SavedOptions savedOptions; int oldExport = (textPtr->exportSelection) && (!Tcl_IsSafe(textPtr->interp)); - int mask = 0; - int selBorderWidth = INT_MIN, spacing1, spacing2, spacing3; + int mask = 0, selBorderWidth = 0, height, highlightWidth; + int borderWidth, spacing1, spacing2, spacing3; int insertBorderWidth, insertWidth, padX, padY; if (Tk_SetOptions(interp, (char *) textPtr, textPtr->optionTable, @@ -2204,6 +2204,41 @@ ConfigureText( * Don't allow negative spacings. */ + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->borderWidthObj, &borderWidth); + if (borderWidth < 0) { + borderWidth = 0; + Tcl_DecrRefCount(textPtr->borderWidthObj); + textPtr->borderWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->borderWidthObj); + } + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->heightObj, &height); + if (height < 0) { + height = 0; + Tcl_DecrRefCount(textPtr->heightObj); + textPtr->heightObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->heightObj); + } + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->highlightWidthObj, &highlightWidth); + if (highlightWidth < 0) { + highlightWidth = 0; + Tcl_DecrRefCount(textPtr->highlightWidthObj); + textPtr->highlightWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->highlightWidthObj); + } + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->insertBorderWidthObj, &insertBorderWidth); + if (insertBorderWidth < 0) { + insertBorderWidth = 0; + Tcl_DecrRefCount(textPtr->insertBorderWidthObj); + textPtr->insertBorderWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->insertBorderWidthObj); + } + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->insertWidthObj, &insertWidth); + if (insertWidth < 0) { + insertWidth = 0; + Tcl_DecrRefCount(textPtr->insertWidthObj); + textPtr->insertWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->insertWidthObj); + } Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->padXObj, &padX); if (padX < 0) { Tcl_DecrRefCount(textPtr->padXObj); @@ -2216,6 +2251,17 @@ ConfigureText( textPtr->padYObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(textPtr->padYObj); } + if (textPtr->selBorderWidthObj) { + Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->selBorderWidthObj, &selBorderWidth); + } + if (selBorderWidth < 0) { + selBorderWidth = 0; + if (textPtr->selBorderWidthObj) { + Tcl_DecrRefCount(textPtr->selBorderWidthObj); + } + textPtr->selBorderWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->selBorderWidthObj); + } Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->spacing1Obj, &spacing1); if (spacing1 < 0) { spacing1 = 0; @@ -2237,32 +2283,6 @@ ConfigureText( textPtr->spacing3Obj = Tcl_NewIntObj(0); Tcl_IncrRefCount(textPtr->spacing3Obj); } - Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->insertBorderWidthObj, &insertBorderWidth); - if (insertBorderWidth < 0) { - insertBorderWidth = 0; - Tcl_DecrRefCount(textPtr->insertBorderWidthObj); - textPtr->insertBorderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(textPtr->insertBorderWidthObj); - } - Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->insertWidthObj, &insertWidth); - if (insertWidth < 0) { - insertWidth = 0; - Tcl_DecrRefCount(textPtr->insertWidthObj); - textPtr->insertWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(textPtr->insertWidthObj); - } - if (textPtr->selBorderWidthObj) { - Tk_GetPixelsFromObj(NULL, textPtr->tkwin, textPtr->selBorderWidthObj, &selBorderWidth); - } - if (selBorderWidth < 0) { - selBorderWidth = 0; - if (textPtr->selBorderWidthObj) { - Tcl_DecrRefCount(textPtr->selBorderWidthObj); - } - textPtr->selBorderWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(textPtr->selBorderWidthObj); - } - /* * Parse tab stops. From 7cfae49ef6bd6554cd56534bda5bdefef8b3a4cb Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 24 Jan 2025 16:59:09 +0000 Subject: [PATCH 11/17] Alphabetise message range checks. Simplify unneeded checks for NULL values --- generic/tkMessage.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/generic/tkMessage.c b/generic/tkMessage.c index 42a4868b8..f2580dba4 100644 --- a/generic/tkMessage.c +++ b/generic/tkMessage.c @@ -488,27 +488,15 @@ ConfigureMessage( * be specified to Tk_ConfigureWidget. */ - Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->widthObj, &width); - if (width < 0) { - if (msgPtr->widthObj) { - Tcl_DecrRefCount(msgPtr->widthObj); - } - msgPtr->widthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(msgPtr->widthObj); - } Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->borderWidthObj, &borderWidth); if (borderWidth < 0) { - if (msgPtr->borderWidthObj) { - Tcl_DecrRefCount(msgPtr->borderWidthObj); - } + Tcl_DecrRefCount(msgPtr->borderWidthObj); msgPtr->borderWidthObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(msgPtr->borderWidthObj); } Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth); if (highlightWidth < 0) { - if (msgPtr->highlightWidthObj) { - Tcl_DecrRefCount(msgPtr->highlightWidthObj); - } + Tcl_DecrRefCount(msgPtr->highlightWidthObj); msgPtr->highlightWidthObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(msgPtr->highlightWidthObj); } @@ -526,6 +514,12 @@ ConfigureMessage( msgPtr->padYObj = NULL; } } + Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->widthObj, &width); + if (width < 0) { + Tcl_DecrRefCount(msgPtr->widthObj); + msgPtr->widthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(msgPtr->widthObj); + } Tk_FreeSavedOptions(&savedOptions); MessageWorldChanged(msgPtr); From 3cc6e9716d1ccf851d27b213a1c16f76f21bf7e9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 25 Jan 2025 11:32:19 +0000 Subject: [PATCH 12/17] Possible fix for [1da19a69f8]: Backspace crashes 9.0 interpreter on FreeBSD --- generic/tkIcu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/generic/tkIcu.c b/generic/tkIcu.c index bdbd8f3d0..f10d55966 100644 --- a/generic/tkIcu.c +++ b/generic/tkIcu.c @@ -287,6 +287,11 @@ Icu_Init( icu_fns.name = (fn_icu_ ## name) \ Tcl_FindSymbol(NULL, icu_fns.lib, symbol) ICU_SYM(open); + if (!icu_fns.open && *icuversion) { + /* FreeBSD doesn't append the ICU version to the symbol name, see [1da19a69f8] */ + *icuversion = 0; + ICU_SYM(open); /* try again without version suffix */ + } ICU_SYM(close); ICU_SYM(preceding); ICU_SYM(following); From c8994cbbdf5997a6f869a52dec753fd724c5ae3a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 25 Jan 2025 11:41:06 +0000 Subject: [PATCH 13/17] (cherry-pick): Fix [080a28104e]: Fixes crash caused by nil UTType when user provides a bogus file type --- macosx/tkMacOSXDialog.c | 54 ++++++++++++++++++++++++++++++++++++++-- macosx/tkMacOSXInit.c | 7 ++++++ macosx/tkMacOSXPrivate.h | 6 +++++ macosx/tkMacOSXTest.c | 7 +++++- tests/filebox.test | 10 ++++++++ 5 files changed, 81 insertions(+), 3 deletions(-) diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index b9ceaff4b..672e26381 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -37,7 +37,9 @@ static void setAllowedFileTypes( NSMutableArray *allowedTypes = [NSMutableArray array]; for (NSString *ext in extensions) { UTType *uttype = [UTType typeWithFilenameExtension: ext]; - [allowedTypes addObject:uttype]; + if (uttype) { + [allowedTypes addObject:uttype]; + } } [panel setAllowedContentTypes:allowedTypes]; } else { @@ -85,6 +87,41 @@ static filepanelFilterInfo filterInfo; static NSOpenPanel *openpanel; static NSSavePanel *savepanel; +/* + * A thread which closes the currently running modal dialog after a timeout. + */ + +@interface TKPanelMonitor: NSThread { +@private + NSTimeInterval _timeout; +} + +- (id) initWithTimeout: (NSTimeInterval) timeout; + +@end + +@implementation TKPanelMonitor: NSThread + +- (id) initWithTimeout: (NSTimeInterval) timeout { + self = [super init]; + if (self) { + _timeout = timeout; + return self; + } + return self; +} + +- (void) main +{ + [NSThread sleepForTimeInterval:_timeout]; + if ([self isCancelled]) { + [NSThread exit]; + } + [NSApp stopModalWithCode:modalCancel]; +} +@end + + static const char *const colorOptionStrings[] = { "-initialcolor", "-parent", "-title", NULL }; @@ -868,7 +905,20 @@ Tk_GetOpenFileObjCmd( parent = nil; parentIsKey = False; } - modalReturnCode = showOpenSavePanel(openpanel, parent, interp, cmdObj, multiple); + TKPanelMonitor *monitor; + if (testsAreRunning) { + /* + * We need the panel to close by itself when running tests. + */ + + monitor = [[TKPanelMonitor alloc] initWithTimeout: 1.0]; + [monitor start]; + } + modalReturnCode = showOpenSavePanel(openpanel, parent, interp, cmdObj, + multiple); + if (testsAreRunning) { + [monitor cancel]; + } if (cmdObj) { Tcl_DecrRefCount(cmdObj); } diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 7d7a690a9..3d0bad485 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -21,6 +21,12 @@ #include #include +/* + * This flag is set if tests are being run. + */ + +int testsAreRunning = 0; + static char tkLibPath[PATH_MAX + 1] = ""; /* @@ -45,6 +51,7 @@ static Tcl_ObjCmdProc TkMacOSVersionObjCmd; @synthesize tkLiveResizeEnded = _tkLiveResizeEnded; @synthesize tkWillExit = _tkWillExit; @synthesize tkPointerWindow = _tkPointerWindow; + - (void) setTkPointerWindow: (TkWindow *)winPtr { if (winPtr) { diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 368f35ba5..e2a52d3e0 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -134,6 +134,12 @@ STRINGIFY(symbol)); \ } +/* + * This is set to 1 if tests are being run. Defined in tkMacOSXInit.c. + */ + +extern int testsAreRunning; + /* * The structure of a 32-bit XEvent keycode on macOS. It may be viewed as * an unsigned int or as having either two or three bitfields. diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index 544707228..185c4a81a 100644 --- a/macosx/tkMacOSXTest.c +++ b/macosx/tkMacOSXTest.c @@ -16,7 +16,6 @@ #include "tkMacOSXConstants.h" #include "tkMacOSXWm.h" - /* * Forward declarations of procedures defined later in this file: */ @@ -48,6 +47,12 @@ int TkplatformtestInit( Tcl_Interp *interp) /* Interpreter to add commands to. */ { + /* + * Set a flag indicating that testing is in progress. + */ + + testsAreRunning = 1; + /* * Add commands for platform specific tests on MacOS here. */ diff --git a/tests/filebox.test b/tests/filebox.test index 2a02fbee6..e21c8e44f 100644 --- a/tests/filebox.test +++ b/tests/filebox.test @@ -23,6 +23,16 @@ test fileDialog-0.2 {GetFileName: file types: MakeFilter() fails} { regsub -all "\0" $msg {\\0} msg list $x $msg } {1 {bad Macintosh file type "\0\0"}} +test fileDialog-0.3 {GetFileName: file types: bad filetype} \ +-constraints {[tk windowingsystem] eq "aqua"} \ +-body { + # Check for the Aqua crash reported in ticket 080a28104. + + set filename [tk_getOpenFile -filetypes { + {"Invalid extension" {x.y}} + {"All files" {*}} + }] +} -result {} set tk_strictMotif_old $tk_strictMotif From d0ae1258ccb4fd02a300952f59c94e3a8c339435 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 25 Jan 2025 15:04:17 +0000 Subject: [PATCH 14/17] Add some comments about the fileDialog-0.3 test. --- tests/filebox.test | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/filebox.test b/tests/filebox.test index e21c8e44f..161e4f53f 100644 --- a/tests/filebox.test +++ b/tests/filebox.test @@ -23,16 +23,20 @@ test fileDialog-0.2 {GetFileName: file types: MakeFilter() fails} { regsub -all "\0" $msg {\\0} msg list $x $msg } {1 {bad Macintosh file type "\0\0"}} +# The next test must actually open a file dialog window, but it does +# not require human interaction to close the dialog because the Aqua +# port of tktest automatically closes every file dialog after a short +# timeout when tests are being run. test fileDialog-0.3 {GetFileName: file types: bad filetype} \ --constraints {[tk windowingsystem] eq "aqua"} \ +-constraints aqua \ -body { - # Check for the Aqua crash reported in ticket 080a28104. - + # Checks for the Aqua crash reported in ticket 080a28104. set filename [tk_getOpenFile -filetypes { {"Invalid extension" {x.y}} {"All files" {*}} }] -} -result {} +} \ +-result {} set tk_strictMotif_old $tk_strictMotif From 617401e17baba672eb02a448567b23409f0264c7 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 25 Jan 2025 16:37:22 +0000 Subject: [PATCH 15/17] Allow all tests to pass on maOS 15 (Sequoia) by compensating for new window placement restrictions. --- tests/text.test | 8 ++++++-- tests/unixWm.test | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/text.test b/tests/text.test index c8cd5c214..1e59560a6 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3486,9 +3486,13 @@ test text-14.18 {ConfigureText procedure} -constraints fonts -setup { # minimum size and it was interfering with the size requested by the -setgrid. # The "overrideredirect" gets rid of the titlebar so the toplevel can shrink # to the appropriate size. -# On macOS, however, there is no way to make the window overlap the menubar. +# On macOS, however, there is no way to make the window overlap the +# menubar. Starting with macOS 16 (Sequoia) it became impossible for +# the y coordinate of the top of a window to be less than 10 plus the +# menubar height (as reported by [[NSApp mainMenu] menuBarHeight]). + if {[tk windowingsystem] eq "aqua"} { - set minY [expr [testmenubarheight] + 1] + set minY [expr [testmenubarheight] + 11] } else { set minY 0 } diff --git a/tests/unixWm.test b/tests/unixWm.test index f8856162a..f1e49dd78 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -36,11 +36,14 @@ proc makeToplevels {} { # On macOS windows are not allowed to overlap the menubar at the top of the # screen or the dock. So tests which move a window and then check whether it # got moved to the requested location should use a y coordinate larger than the -# height of the menubar (normally 23 pixels) and an x coordinate larger than the -# width of the dock, if it happens to be on the left. +# height of the menubar (normally 23 pixels) and an x coordinate larger than +# the width of the dock, if it happens to be on the left. Starting with +# macOS 16 (Sequoia) it became impossible for the y coordinate of the top +# of a window to be less than 10 plus the menubar height (as reported by +# [[NSApp mainMenu] menuBarHeight]). if {[tk windowingsystem] eq "aqua"} { - set mb [expr [testmenubarheight] + 1] + set mb [expr [testmenubarheight] + 11] set X 100 set Y0 $mb set Y2 [expr $mb + 2] From aafb3579a91fe5df007e253b25a50ec5dcab59f5 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 25 Jan 2025 17:02:25 +0000 Subject: [PATCH 16/17] Correct typo. --- tests/text.test | 2 +- tests/unixWm.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/text.test b/tests/text.test index 1e59560a6..4e735df1a 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3487,7 +3487,7 @@ test text-14.18 {ConfigureText procedure} -constraints fonts -setup { # The "overrideredirect" gets rid of the titlebar so the toplevel can shrink # to the appropriate size. # On macOS, however, there is no way to make the window overlap the -# menubar. Starting with macOS 16 (Sequoia) it became impossible for +# menubar. Starting with macOS 15 (Sequoia) it became impossible for # the y coordinate of the top of a window to be less than 10 plus the # menubar height (as reported by [[NSApp mainMenu] menuBarHeight]). diff --git a/tests/unixWm.test b/tests/unixWm.test index f1e49dd78..9d0c8352d 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -38,7 +38,7 @@ proc makeToplevels {} { # got moved to the requested location should use a y coordinate larger than the # height of the menubar (normally 23 pixels) and an x coordinate larger than # the width of the dock, if it happens to be on the left. Starting with -# macOS 16 (Sequoia) it became impossible for the y coordinate of the top +# macOS 15 (Sequoia) it became impossible for the y coordinate of the top # of a window to be less than 10 plus the menubar height (as reported by # [[NSApp mainMenu] menuBarHeight]). From 7f5b66f4fa9f9897faf8cff87a4ec418363d3bae Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 25 Jan 2025 17:33:57 +0000 Subject: [PATCH 17/17] Move some checks in alphabetical order. Backported from 9.0 --- generic/tkButton.c | 24 ++++++++++++++++++------ generic/tkFrame.c | 10 +++++----- generic/tkMessage.c | 6 +++--- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/generic/tkButton.c b/generic/tkButton.c index 7ad122f88..7f3bb4563 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -1097,12 +1097,6 @@ ConfigureButton( } else { Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->normalBorder); } - if (butPtr->wrapLength < 0) { - butPtr->wrapLength = 0; - Tcl_DecrRefCount(butPtr->wrapLengthPtr); - butPtr->wrapLengthPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(butPtr->wrapLengthPtr); - } if (butPtr->borderWidth < 0) { butPtr->borderWidth = 0; Tcl_DecrRefCount(butPtr->borderWidthPtr); @@ -1127,6 +1121,12 @@ ConfigureButton( butPtr->padYPtr = Tcl_NewIntObj(0); Tcl_IncrRefCount(butPtr->padYPtr); } + if (butPtr->wrapLength < 0) { + butPtr->wrapLength = 0; + Tcl_DecrRefCount(butPtr->wrapLengthPtr); + butPtr->wrapLengthPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(butPtr->wrapLengthPtr); + } if (butPtr->type >= TYPE_CHECK_BUTTON) { Tcl_Obj *valuePtr, *namePtr; @@ -1299,6 +1299,18 @@ ConfigureButton( goto heightError; } } + if (butPtr->width < 0) { + butPtr->width = 0; + Tcl_DecrRefCount(butPtr->widthPtr); + butPtr->widthPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(butPtr->widthPtr); + } + if (butPtr->height < 0) { + butPtr->height = 0; + Tcl_DecrRefCount(butPtr->heightPtr); + butPtr->heightPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(butPtr->heightPtr); + } break; } if (!error) { diff --git a/generic/tkFrame.c b/generic/tkFrame.c index a9783816e..90244ab34 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -1042,15 +1042,12 @@ ConfigureFrame( Tk_SetWindowBackgroundPixmap(framePtr->tkwin, None); } - if (framePtr->width < 0) { - framePtr->width = 0; + if (framePtr->borderWidth < 0) { + framePtr->borderWidth = 0; } if (framePtr->height < 0) { framePtr->height = 0; } - if (framePtr->borderWidth < 0) { - framePtr->borderWidth = 0; - } if (framePtr->highlightWidth < 0) { framePtr->highlightWidth = 0; } @@ -1066,6 +1063,9 @@ ConfigureFrame( framePtr->padYObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(framePtr->padYObj); } + if (framePtr->width < 0) { + framePtr->width = 0; + } /* * If a -labelwidget is specified, check that it is valid and set up diff --git a/generic/tkMessage.c b/generic/tkMessage.c index 5c5589ca2..c6e6e18b9 100644 --- a/generic/tkMessage.c +++ b/generic/tkMessage.c @@ -488,9 +488,6 @@ ConfigureMessage( * be specified to Tk_ConfigureWidget. */ - if (msgPtr->width < 0) { - msgPtr->width = 0; - } if (msgPtr->borderWidth < 0) { msgPtr->borderWidth = 0; } @@ -521,6 +518,9 @@ ConfigureMessage( Tcl_IncrRefCount(msgPtr->padYObj); } } + if (msgPtr->width < 0) { + msgPtr->width = 0; + } Tk_FreeSavedOptions(&savedOptions); MessageWorldChanged(msgPtr);