Index: include/OpenEXR/ImfAttribute.h =================================================================== --- include/OpenEXR/ImfAttribute.h (revision 169) +++ include/OpenEXR/ImfAttribute.h (working copy) @@ -106,7 +106,12 @@ static bool knownType (const char typeName[]); + //------------------------------------------------------ + // Un-register all known attributes. + //------------------------------------------------------ + static void clearAttributeRegistration(); + protected: //-------------------------------------------------- Index: include/OpenEXR/ImfHeader.h =================================================================== --- include/OpenEXR/ImfHeader.h (revision 169) +++ include/OpenEXR/ImfHeader.h (working copy) @@ -493,6 +493,7 @@ //------------------------------------------------------------------------ void staticInitialize (); +void staticUninitialize (); //----------------- Index: src/lib/IlmImf/ImfAttribute.cpp =================================================================== --- src/lib/IlmImf/ImfAttribute.cpp (revision 169) +++ src/lib/IlmImf/ImfAttribute.cpp (working copy) @@ -83,22 +83,32 @@ Mutex mutex; }; +static Mutex criticalSection; +static LockedTypeMap* typeMapVar = 0; LockedTypeMap & typeMap () { - static Mutex criticalSection; Lock lock (criticalSection); - static LockedTypeMap* typeMap = 0; + if (typeMapVar == 0) + typeMapVar = new LockedTypeMap (); - if (typeMap == 0) - typeMap = new LockedTypeMap (); + return *typeMapVar; +} - return *typeMap; +void +clearTypeMap () +{ + Lock lock (criticalSection); + + if (typeMapVar != 0) + { + delete typeMapVar; + typeMapVar = 0; + } } - } // namespace @@ -137,7 +147,16 @@ tMap.erase (typeName); } +void + Attribute::clearAttributeRegistration () +{ + LockedTypeMap& tMap = typeMap(); + Lock lock (tMap.mutex); + tMap.clear (); + clearTypeMap(); +} + Attribute * Attribute::newAttribute (const char typeName[]) { Index: src/lib/IlmImf/ImfHeader.cpp =================================================================== --- src/lib/IlmImf/ImfHeader.cpp (revision 169) +++ src/lib/IlmImf/ImfHeader.cpp (working copy) @@ -1229,15 +1229,14 @@ } } +static bool initialized = false; +static Mutex criticalSection; void staticInitialize () { - static Mutex criticalSection; Lock lock (criticalSection); - static bool initialized = false; - if (!initialized) { // @@ -1277,5 +1276,14 @@ } } +void +staticUninitialize () +{ + Lock lock (criticalSection); + Attribute::clearAttributeRegistration(); + + initialized = false; +} + OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT