diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-09-22 20:23:32 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-09-22 20:23:32 (GMT) |
commit | 84cc698d477dbbd222865430555e817758524876 (patch) | |
tree | f8043d44e546ccd915a6a1986fe3d9a1c4c99217 | |
parent | 47b050989a2ad98b4b975fb2f8811f42cea01cd8 (diff) | |
parent | 2f7d3ca46fb2619edc3360671e0aa909803b0c40 (diff) | |
download | tk-84cc698d477dbbd222865430555e817758524876.zip tk-84cc698d477dbbd222865430555e817758524876.tar.gz tk-84cc698d477dbbd222865430555e817758524876.tar.bz2 |
Workaround for [36e379c01b]: macOS Ventura, X11 build with XQuartz: crash in XLoadQueryFont
-rw-r--r-- | tests/entry.test | 6 | ||||
-rw-r--r-- | tests/spinbox.test | 6 | ||||
-rw-r--r-- | unix/tkUnixFont.c | 39 |
3 files changed, 37 insertions, 14 deletions
diff --git a/tests/entry.test b/tests/entry.test index 1be9b7e..82259b1 100644 --- a/tests/entry.test +++ b/tests/entry.test @@ -11,8 +11,6 @@ namespace import ::tcltest::* eval tcltest::configure $argv tcltest::loadTestedCommands -testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }] - # For xscrollcommand set scrollInfo {} proc scroll args { @@ -893,7 +891,7 @@ test entry-3.23 {EntryWidgetCmd procedure, "delete" widget command} -setup { } -cleanup { destroy .e } -result 0123457890 -test entry-3.24 {EntryWidgetCmd procedure, "delete" widget command} -constraints failsOnXQuarz -setup { +test entry-3.24 {EntryWidgetCmd procedure, "delete" widget command} -setup { entry .e pack .e ; update idletasks update @@ -1011,7 +1009,7 @@ test entry-3.34 {EntryWidgetCmd procedure, "index" widget command} -setup { } -cleanup { destroy .e } -returnCodes {ok} -match glob -result {*} -test entry-3.35 {EntryWidgetCmd procedure, "index" widget command} -constraints failsOnXQuarz -setup { +test entry-3.35 {EntryWidgetCmd procedure, "index" widget command} -setup { entry .e pack .e ; update idletasks update diff --git a/tests/spinbox.test b/tests/spinbox.test index 06359bc..87fb946 100644 --- a/tests/spinbox.test +++ b/tests/spinbox.test @@ -11,8 +11,6 @@ namespace import ::tcltest::* eval tcltest::configure $argv tcltest::loadTestedCommands -testConstraint failsOnXQuarz [expr {$tcl_platform(os) ne "Darwin" || [tk windowingsystem] ne "x11" }] - # For xscrollcommand set scrollInfo {} proc scroll args { @@ -1231,7 +1229,7 @@ test spinbox-3.23 {SpinboxWidgetCmd procedure, "delete" widget command} -setup { } -cleanup { destroy .e } -result 0123457890 -test spinbox-3.24 {SpinboxWidgetCmd procedure, "delete" widget command} -constraints failsOnXQuarz -setup { +test spinbox-3.24 {SpinboxWidgetCmd procedure, "delete" widget command} -setup { spinbox .e pack .e update @@ -1349,7 +1347,7 @@ test spinbox-3.34 {SpinboxWidgetCmd procedure, "index" widget command} -setup { } -cleanup { destroy .e } -returnCodes {ok} -match glob -result {*} -test spinbox-3.35 {SpinboxWidgetCmd procedure, "index" widget command} -constraints failsOnXQuarz -setup { +test spinbox-3.35 {SpinboxWidgetCmd procedure, "index" widget command} -setup { spinbox .e pack .e update diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index da75d0f..6ff53cf 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -242,6 +242,33 @@ static int SeenName(const char *name, Tcl_DString *dsPtr); /* *------------------------------------------------------------------------- * + * XLoadQueryFontNoXError -- + * + * This function is XLoadQueryFont wrapped in a NULL error handler. + * It is a temporary workaround for ticket [36e379c01b], + * "macOS Ventura, X11 build with XQuartz: crash in XLoadQueryFont", + * which actually is issue #216 in XQuartz: + * https://github.com/XQuartz/XQuartz/issues/216 + * + *------------------------------------------------------------------------- + */ + +static XFontStruct * +XLoadQueryFontNoXError(Display *display, char *name) +{ + XFontStruct *fontStructPtr = NULL; + Tk_ErrorHandler handler; + + /* 45 is the major opcode of X_OpenFont */ + handler = Tk_CreateErrorHandler(display, BadValue, 45, -1, NULL, NULL); + fontStructPtr = XLoadQueryFont(display, name); + Tk_DeleteErrorHandler(handler); + return fontStructPtr; +} + +/* + *------------------------------------------------------------------------- + * * FontPkgCleanup -- * * This function is called when an application is created. It initializes @@ -490,7 +517,7 @@ TkpGetNativeFont( return NULL; } - fontStructPtr = XLoadQueryFont(Tk_Display(tkwin), name); + fontStructPtr = XLoadQueryFontNoXError(Tk_Display(tkwin), (char *)name); if (fontStructPtr == NULL) { /* * Handle all names that look like XLFDs here. Otherwise, when @@ -745,7 +772,7 @@ void TkpGetFontAttrsForChar( Tk_Window tkwin, /* Window on the font's display */ Tk_Font tkfont, /* Font to query */ - int c, /* Character of interest */ + int c, /* Character of interest */ TkFontAttributes *faPtr) /* Output: Font attributes */ { FontAttributes atts; @@ -2603,11 +2630,11 @@ GetScreenFont( snprintf(buf, sizeof(buf), "%.200s-%d-*-*-*-*-*%s", nameList[bestIdx[1]], (int)(-wantPtr->fa.size+0.5), rest); *str = '-'; - fontStructPtr = XLoadQueryFont(display, buf); + fontStructPtr = XLoadQueryFontNoXError(display, buf); bestScore[1] = INT_MAX; } if (fontStructPtr == NULL) { - fontStructPtr = XLoadQueryFont(display, nameList[bestIdx[0]]); + fontStructPtr = XLoadQueryFontNoXError(display, nameList[bestIdx[0]]); if (fontStructPtr == NULL) { /* * This shouldn't happen because the font name is one of the names @@ -2647,9 +2674,9 @@ GetSystemFont( { XFontStruct *fontStructPtr; - fontStructPtr = XLoadQueryFont(display, "fixed"); + fontStructPtr = XLoadQueryFontNoXError(display, "fixed"); if (fontStructPtr == NULL) { - fontStructPtr = XLoadQueryFont(display, "*"); + fontStructPtr = XLoadQueryFontNoXError(display, "*"); if (fontStructPtr == NULL) { Tcl_Panic("TkpGetFontFromAttributes: cannot get any font"); } |