From 835237028039d23f5fed5101137f18e45a1b68a7 Mon Sep 17 00:00:00 2001 From: hobbs Date: Fri, 12 Apr 2002 07:35:42 +0000 Subject: * unix/tkUnixFont.c (FontPkgCleanup): cleanup thread specific font resources on thread exit. --- unix/tkUnixFont.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 5575e09..444eebb 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixFont.c,v 1.10 2002/03/27 00:14:06 andreas_kupries Exp $ + * RCS: @(#) $Id: tkUnixFont.c,v 1.11 2002/04/12 07:35:42 hobbs Exp $ */ #include "tkUnixInt.h" @@ -198,6 +198,7 @@ static EncodingAlias encodingAliases[] = { * Procedures used only in this file. */ +static void FontPkgCleanup _ANSI_ARGS_((ClientData clientData)); static FontFamily * AllocFontFamily _ANSI_ARGS_((Display *display, XFontStruct *fontStructPtr, int base)); static SubFont * CanUseFallback _ANSI_ARGS_((UnixFont *fontPtr, @@ -262,6 +263,44 @@ static int UtfToUcs2beProc _ANSI_ARGS_((ClientData clientData, /* *------------------------------------------------------------------------- * + * FontPkgCleanup -- + * + * This procedure 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: + * None. + * + * Side effects: + * Releases thread-specific resources used by font pkg. + * + *------------------------------------------------------------------------- + */ + +static void +FontPkgCleanup(ClientData clientData) +{ + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + + if (tsdPtr->controlFamily.encoding != NULL) { + FontFamily *familyPtr = &tsdPtr->controlFamily; + int i; + + Tcl_FreeEncoding(familyPtr->encoding); + for (i = 0; i < FONTMAP_PAGES; i++) { + if (familyPtr->fontMap[i] != NULL) { + ckfree(familyPtr->fontMap[i]); + } + } + tsdPtr->controlFamily.encoding = NULL; + } +} + +/* + *------------------------------------------------------------------------- + * * TkpFontPkgInit -- * * This procedure is called when an application is created. It @@ -318,6 +357,7 @@ TkpFontPkgInit(mainPtr) type.clientData = NULL; type.nullSize = 2; Tcl_CreateEncoding(&type); + Tcl_CreateThreadExitHandler(FontPkgCleanup, NULL); } } -- cgit v0.12