summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixFont.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2002-04-12 07:35:42 (GMT)
committerhobbs <hobbs>2002-04-12 07:35:42 (GMT)
commitce1053e1b83c693a7741bbe9e480ce2fb6d6de06 (patch)
tree295000349ba344b19500b88f7f27b9f52b32ca01 /unix/tkUnixFont.c
parent8059f11608e8cef03fb9e8c72ecba88471abf6b7 (diff)
downloadtk-ce1053e1b83c693a7741bbe9e480ce2fb6d6de06.zip
tk-ce1053e1b83c693a7741bbe9e480ce2fb6d6de06.tar.gz
tk-ce1053e1b83c693a7741bbe9e480ce2fb6d6de06.tar.bz2
* unix/tkUnixFont.c (FontPkgCleanup): cleanup thread specific font
resources on thread exit.
Diffstat (limited to 'unix/tkUnixFont.c')
-rw-r--r--unix/tkUnixFont.c42
1 files changed, 41 insertions, 1 deletions
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);
}
}