Tk Source Code

Changes On Branch bug-36e379c01b
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch bug-36e379c01b Excluding Merge-Ins

This is equivalent to a diff from efcd1b3d to 7f20f599

2024-09-22
20:23
Workaround for [36e379c01b]: macOS Ventura, X11 build with XQuartz: crash in XLoadQueryFont check-in: d2f53df7 user: jan.nijtmans tags: trunk, main
2024-09-21
15:47
Improved the appearance of the Treeitem.indicator element. check-in: e716730b user: csaba tags: trunk, main
2024-09-20
18:56
Try a workaround for [36e379c01b] (Which - actually - is a bug in XQuarz) Closed-Leaf check-in: 7f20f599 user: jan.nijtmans tags: bug-36e379c01b
16:59
Fix [3981091e] Segmentation fault with bogus resource value (X11) check-in: efcd1b3d user: jan.nijtmans tags: trunk, main
16:57
Fix [3981091e] Segmentation fault with bogus resource value (X11) check-in: 7013ecaf user: jan.nijtmans tags: core-8-branch
2024-09-19
21:01
Fix [18e9840f84]: Assignment of invalid symbolic constant NotifyNormal check-in: 7c5f7fff user: fvogel tags: trunk, main
2024-09-15
10:38
Abandon the 'XQuartzKnownBug' constraint way and gear a specific error handler catching 'X Error of failed request: BadValue (X_OpenFont)' when calling XLoadQueryFont. check-in: b128b1a3 user: fvogel tags: less_tests_constraints

Changes to tests/entry.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1
2
3
4
5
6
7
8
9
10
11
12
13


14
15
16
17
18
19
20













-
-







# This file is a Tcl script to test entry widgets in Tk.  It is
# organized in the standard fashion for Tcl tests.
#
# Copyright © 1994 The Regents of the University of California.
# Copyright © 1994-1997 Sun Microsystems, Inc.
# Copyright © 1998-1999 Scriptics Corporation.
# All rights reserved.

package require tcltest 2.2
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 {
    global scrollInfo
    set scrollInfo $args
}
# For trace add variable
889
890
891
892
893
894
895
896

897
898
899
900
901
902
903
887
888
889
890
891
892
893

894
895
896
897
898
899
900
901







-
+







} -body {
    .e insert end "01234567890"
    .e delete 6
    .e get
} -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
    set x {}
} -body {
# UTF
    .e insert end "01234乎67890"
1007
1008
1009
1010
1011
1012
1013
1014

1015
1016
1017
1018
1019
1020
1021
1005
1006
1007
1008
1009
1010
1011

1012
1013
1014
1015
1016
1017
1018
1019







-
+







    pack .e ; update idletasks
    update
} -body {
    .e index 0
} -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
} -body {
# UTF
    .e insert 0 abc乎œdef
    list [.e index 3] [.e index 4] [.e index end]
Changes to tests/spinbox.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1
2
3
4
5
6
7
8
9
10
11
12
13


14
15
16
17
18
19
20













-
-







# This file is a Tcl script to test spinbox widgets in Tk.  It is
# organized in the standard fashion for Tcl tests.
#
# Copyright © 1994 The Regents of the University of California.
# Copyright © 1994-1997 Sun Microsystems, Inc.
# Copyright © 1998-1999 Scriptics Corporation.
# All rights reserved.

package require tcltest 2.2
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 {
    global scrollInfo
    set scrollInfo $args
}
# For trace add variable
1227
1228
1229
1230
1231
1232
1233
1234

1235
1236
1237
1238
1239
1240
1241
1225
1226
1227
1228
1229
1230
1231

1232
1233
1234
1235
1236
1237
1238
1239







-
+







} -body {
    .e insert end "01234567890"
    .e delete 6
    .e get
} -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
    set x {}
} -body {
# UTF
    .e insert end "01234乎67890"
1345
1346
1347
1348
1349
1350
1351
1352

1353
1354
1355
1356
1357
1358
1359
1343
1344
1345
1346
1347
1348
1349

1350
1351
1352
1353
1354
1355
1356
1357







-
+







    pack .e
    update
} -body {
    .e index 0
} -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
} -body {
# UTF
    .e insert 0 abc乎œdef
    list [.e index 3] [.e index 4] [.e index end]
Changes to unix/tkUnixFont.c.
238
239
240
241
242
243
244



























245
246
247
248
249
250
251
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







static void		ReleaseFont(UnixFont *fontPtr);
static void		ReleaseSubFont(Display *display, SubFont *subFontPtr);
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
 *	all the structures that are used by the platform-dependent code on a
 *	per application basis.
 *
 * Results:
486
487
488
489
490
491
492
493

494
495
496
497
498
499
500
513
514
515
516
517
518
519

520
521
522
523
524
525
526
527







-
+







	    hasWild = 1;
	}
    }
    if ((dashes < 14) && !hasWild && hasSpace) {
	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
	 * TkpGetFontFromAttributes is called from generic code, any foundry
	 * or encoding information specified in the XLFD will have been parsed
	 * out and lost. But make sure we don't have an "-option value" string
	 * since TkFontParseXLFD would return a false success when attempting
741
742
743
744
745
746
747
748

749
750
751
752
753
754
755
768
769
770
771
772
773
774

775
776
777
778
779
780
781
782







-
+







 *----------------------------------------------------------------------
 */

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;
    UnixFont *fontPtr = (UnixFont *) tkfont;
				/* Structure describing the logical font */
    SubFont *lastSubFontPtr = &fontPtr->subFontArray[0];
				/* Pointer to subfont array in case
2599
2600
2601
2602
2603
2604
2605
2606

2607
2608
2609
2610

2611
2612
2613
2614
2615
2616
2617
2626
2627
2628
2629
2630
2631
2632

2633
2634
2635
2636

2637
2638
2639
2640
2641
2642
2643
2644







-
+



-
+







	for (i = XLFD_PIXEL_SIZE; i < XLFD_CHARSET; i++) {
	    rest = strchr(rest + 1, '-');
	}
	*str = '\0';
	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
	     * that X gave us to use, but it does anyhow.
	     */

	    if (bestScore[1] < INT_MAX) {
2643
2644
2645
2646
2647
2648
2649
2650

2651
2652

2653
2654
2655
2656
2657
2658
2659
2670
2671
2672
2673
2674
2675
2676

2677
2678

2679
2680
2681
2682
2683
2684
2685
2686







-
+

-
+








static XFontStruct *
GetSystemFont(
    Display *display)		/* Display for new XFontStruct. */
{
    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");
	}
    }
    return fontStructPtr;
}