summaryrefslogtreecommitdiffstats
path: root/generic/tkImgPhoto.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkImgPhoto.c')
-rw-r--r--generic/tkImgPhoto.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 285f1df..9fb74e6 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -11,7 +11,11 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkImgPhoto.c,v 1.5 1999/03/10 07:04:39 stanton Exp $
+ * Author: Paul Mackerras (paulus@cs.anu.edu.au),
+ * Department of Computer Science,
+ * Australian National University.
+ *
+ * RCS: @(#) $Id: tkImgPhoto.c,v 1.6 1999/04/16 01:51:15 stanton Exp $
*/
#include "tkInt.h"
@@ -293,6 +297,12 @@ Tk_ImageType tkPhotoImageType = {
(Tk_ImageType *) NULL /* nextPtr */
};
+typedef struct ThreadSpecificData {
+ Tk_PhotoImageFormat *formatList; /* Pointer to the first in the
+ * list of known photo image formats.*/
+} ThreadSpecificData;
+static Tcl_ThreadDataKey dataKey;
+
/*
* Default configuration
*/
@@ -334,12 +344,6 @@ static int imgPhotoColorHashInitialized;
#define N_COLOR_HASH (sizeof(ColorTableId) / sizeof(int))
/*
- * Pointer to the first in the list of known photo image formats.
- */
-
-static Tk_PhotoImageFormat *formatList = NULL;
-
-/*
* Forward declarations
*/
@@ -419,13 +423,15 @@ Tk_CreatePhotoImageFormat(formatPtr)
* to Tk_CreatePhotoImageFormat previously. */
{
Tk_PhotoImageFormat *copyPtr;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
copyPtr = (Tk_PhotoImageFormat *) ckalloc(sizeof(Tk_PhotoImageFormat));
*copyPtr = *formatPtr;
copyPtr->name = (char *) ckalloc((unsigned) (strlen(formatPtr->name) + 1));
strcpy(copyPtr->name, formatPtr->name);
- copyPtr->nextPtr = formatList;
- formatList = copyPtr;
+ copyPtr->nextPtr = tsdPtr->formatList;
+ tsdPtr->formatList = copyPtr;
}
/*
@@ -526,7 +532,6 @@ ImgPhotoCmd(clientData, interp, argc, argv)
unsigned char *pixelPtr;
Tk_PhotoImageBlock block;
Tk_Window tkwin;
- char string[16];
XColor color;
Tk_PhotoImageFormat *imageFormat;
int imageWidth, imageHeight;
@@ -534,6 +539,8 @@ ImgPhotoCmd(clientData, interp, argc, argv)
Tcl_Channel chan;
Tk_PhotoHandle srcHandle;
size_t length;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (argc < 2) {
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
@@ -682,6 +689,8 @@ ImgPhotoCmd(clientData, interp, argc, argv)
* photo get command - first parse and check parameters.
*/
+ char string[TCL_INTEGER_SPACE * 3];
+
if (argc != 4) {
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" get x y\"", (char *) NULL);
@@ -978,7 +987,7 @@ ImgPhotoCmd(clientData, interp, argc, argv)
*/
matched = 0;
- for (imageFormat = formatList; imageFormat != NULL;
+ for (imageFormat = tsdPtr->formatList; imageFormat != NULL;
imageFormat = imageFormat->nextPtr) {
if ((options.format == NULL)
|| (strncasecmp(options.format, imageFormat->name,
@@ -1258,7 +1267,7 @@ ParseSubcommandOptions(optPtr, interp, allowedOptions, optIndexPtr, argc, argv)
*
* Results:
* A standard Tcl return value. If TCL_ERROR is returned then
- * an error message is left in masterPtr->interp->result.
+ * an error message is left in the masterPtr->interp's result.
*
* Side effects:
* Existing instances of the image will be redisplayed to match
@@ -1601,7 +1610,7 @@ ImgPhotoGet(tkwin, masterData)
int mono, nRed, nGreen, nBlue;
XVisualInfo visualInfo, *visInfoPtr;
XRectangle validBox;
- char buf[16];
+ char buf[TCL_INTEGER_SPACE * 3];
int numVisuals;
XColor *white, *black;
XGCValues gcValues;
@@ -3022,6 +3031,8 @@ MatchFileFormat(interp, chan, fileName, formatString, imageFormatPtr,
{
int matched;
Tk_PhotoImageFormat *formatPtr;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
* Scan through the table of file format handlers to find
@@ -3029,7 +3040,7 @@ MatchFileFormat(interp, chan, fileName, formatString, imageFormatPtr,
*/
matched = 0;
- for (formatPtr = formatList; formatPtr != NULL;
+ for (formatPtr = tsdPtr->formatList; formatPtr != NULL;
formatPtr = formatPtr->nextPtr) {
if (formatString != NULL) {
if (strncasecmp(formatString, formatPtr->name,
@@ -3112,6 +3123,8 @@ MatchStringFormat(interp, string, formatString, imageFormatPtr,
{
int matched;
Tk_PhotoImageFormat *formatPtr;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
* Scan through the table of file format handlers to find
@@ -3119,7 +3132,7 @@ MatchStringFormat(interp, string, formatString, imageFormatPtr,
*/
matched = 0;
- for (formatPtr = formatList; formatPtr != NULL;
+ for (formatPtr = tsdPtr->formatList; formatPtr != NULL;
formatPtr = formatPtr->nextPtr) {
if (formatString != NULL) {
if (strncasecmp(formatString, formatPtr->name,