From e137dfcaa4792db829fb91ccde8a57f3d266043e Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 14 May 2012 16:58:44 +0000 Subject: [PATCH] fix thread-unsafe tga loader --- panda/src/pnmimagetypes/pnmFileTypeTGA.cxx | 9 ++++++--- panda/src/pnmimagetypes/pnmFileTypeTGA.h | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx index ac1bcfd6c7..98dc389348 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx @@ -199,6 +199,12 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : ColorMap = NULL; AlphaMap = NULL; + Red = 0; + Grn = 0; + Blu = 0; + Alpha = 0; + l = 0; + /* Read the Targa file header. */ readtga( file, tga_head, magic_number ); /* @@ -701,10 +707,7 @@ get_map_entry( istream *ifp, pixel *Value, int Size, gray *Alpha ) { void PNMFileTypeTGA::Reader:: get_pixel( istream *ifp, pixel *dest, int Size, gray *alpha_p) { - static pixval Red, Grn, Blu; - static pixval Alpha; unsigned char j, k; - static unsigned int l; /* Check if run length encoded. */ if ( rlencoded ) diff --git a/panda/src/pnmimagetypes/pnmFileTypeTGA.h b/panda/src/pnmimagetypes/pnmFileTypeTGA.h index 2a20d13816..8b676bd848 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTGA.h +++ b/panda/src/pnmimagetypes/pnmFileTypeTGA.h @@ -66,6 +66,10 @@ public: pixel *ColorMap; gray *AlphaMap; int RLE_count, RLE_flag; + + pixval Red, Grn, Blu; + pixval Alpha; + unsigned int l; }; class Writer : public PNMWriter {