From 58d5a950146d3e9f05242e8dac90df955c1fa930 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 8 Jan 2023 19:46:59 +0000 Subject: Fix [cee095ab5a]: X error handler not uninstalled in tkUnixRFont.c, Tk_MeasureChars --- unix/tkUnixRFont.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 8eb6f53..a295173 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -208,7 +208,7 @@ GetTkFontAttributes( slant = XFT_SLANT_ROMAN; } -#if DEBUG_FONTSEL +#ifdef DEBUG_FONTSEL printf("family %s size %d weight %d slant %d\n", family, (int)size, weight, slant); #endif /* DEBUG_FONTSEL */ @@ -457,7 +457,7 @@ TkpGetNativeFont( { UnixFtFont *fontPtr; FcPattern *pattern; -#if DEBUG_FONTSEL +#ifdef DEBUG_FONTSEL printf("TkpGetNativeFont %s\n", name); #endif /* DEBUG_FONTSEL */ @@ -495,7 +495,7 @@ TkpGetFontFromAttributes( int weight, slant; UnixFtFont *fontPtr; -#if DEBUG_FONTSEL +#ifdef DEBUG_FONTSEL printf("TkpGetFontFromAttributes %s-%d %d %d\n", faPtr->family, faPtr->size, faPtr->weight, faPtr->slant); #endif /* DEBUG_FONTSEL */ @@ -675,9 +675,9 @@ TkpGetSubFonts( void TkpGetFontAttrsForChar( - TCL_UNUSED(Tk_Window), /* Window on the font's display */ + TCL_UNUSED(Tk_Window), /* 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 */ { UnixFtFont *fontPtr = (UnixFtFont *) tkfont; @@ -722,7 +722,7 @@ Tk_MeasureChars( int clen, curX, newX, curByte, newByte, sawNonSpace; int termByte = 0, termX = 0, errorFlag = 0; Tk_ErrorHandler handler; -#if DEBUG_FONTSEL +#ifdef DEBUG_FONTSEL char string[256]; int len = 0; #endif /* DEBUG_FONTSEL */ @@ -743,8 +743,7 @@ Tk_MeasureChars( * This can't happen (but see #1185640) */ - *lengthPtr = curX; - return curByte; + goto measureCharsEnd; } source += clen; @@ -759,7 +758,7 @@ Tk_MeasureChars( sawNonSpace = 1; } -#if DEBUG_FONTSEL +#ifdef DEBUG_FONTSEL string[len++] = (char) c; #endif /* DEBUG_FONTSEL */ ftFont = GetFont(fontPtr, c, 0.0); @@ -800,8 +799,9 @@ Tk_MeasureChars( curX = newX; curByte = newByte; } +measureCharsEnd: Tk_DeleteErrorHandler(handler); -#if DEBUG_FONTSEL +#ifdef DEBUG_FONTSEL string[len] = '\0'; printf("MeasureChars %s length %d bytes %d\n", string, curX, curByte); #endif /* DEBUG_FONTSEL */ @@ -813,15 +813,13 @@ int TkpMeasureCharsInContext( Tk_Font tkfont, const char *source, - int numBytes, + TCL_UNUSED(int), int rangeStart, int rangeLength, int maxLength, int flags, int *lengthPtr) { - (void) numBytes; /*unused*/ - return Tk_MeasureChars(tkfont, source + rangeStart, rangeLength, maxLength, flags, lengthPtr); } @@ -941,7 +939,7 @@ Tk_DrawChars( Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (fontPtr->ftDraw == 0) { -#if DEBUG_FONTSEL +#ifdef DEBUG_FONTSEL printf("Switch to drawable 0x%x\n", drawable); #endif /* DEBUG_FONTSEL */ fontPtr->ftDraw = XftDrawCreate(display, drawable, @@ -1082,7 +1080,7 @@ TkDrawAngledChars( int originX, originY; if (fontPtr->ftDraw == 0) { -#if DEBUG_FONTSEL +#ifdef DEBUG_FONTSEL printf("Switch to drawable 0x%x\n", drawable); #endif /* DEBUG_FONTSEL */ fontPtr->ftDraw = XftDrawCreate(display, drawable, @@ -1200,7 +1198,7 @@ TkDrawAngledChars( double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0); if (fontPtr->ftDraw == 0) { -#if DEBUG_FONTSEL +#ifdef DEBUG_FONTSEL printf("Switch to drawable 0x%x\n", drawable); #endif /* DEBUG_FONTSEL */ fontPtr->ftDraw = XftDrawCreate(display, drawable, @@ -1367,7 +1365,7 @@ TkpDrawCharsInContext( * is passed to this function. If they are not * stripped out, they will be displayed as * regular printing characters. */ - int numBytes, /* Number of bytes in string. */ + TCL_UNUSED(int), /* Number of bytes in string. */ int rangeStart, /* Index of first byte to draw. */ int rangeLength, /* Length of range to draw in bytes. */ int x, int y) /* Coordinates at which to place origin of the @@ -1376,8 +1374,6 @@ TkpDrawCharsInContext( { int widthUntilStart; - (void) numBytes; /*unused*/ - Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart); Tk_DrawChars(display, drawable, gc, tkfont, source + rangeStart, rangeLength, x+widthUntilStart, y); @@ -1397,7 +1393,7 @@ TkpDrawAngledCharsInContext( * passed to this function. If they are not * stripped out, they will be displayed as * regular printing characters. */ - int numBytes, /* Number of bytes in string. */ + TCL_UNUSED(int), /* Number of bytes in string. */ int rangeStart, /* Index of first byte to draw. */ int rangeLength, /* Length of range to draw in bytes. */ double x, double y, /* Coordinates at which to place origin of the @@ -1408,8 +1404,6 @@ TkpDrawAngledCharsInContext( int widthUntilStart; double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0); - (void) numBytes; /*unused*/ - Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart); TkDrawAngledChars(display, drawable, gc, tkfont, source + rangeStart, rangeLength, x+cosA*widthUntilStart, y-sinA*widthUntilStart, angle); -- cgit v0.12