From 22fdc63b862533e5d7dc1e8b5e3b4f6056668363 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 18 Sep 2012 19:20:26 +0000 Subject: Color management: fix crashes and memory leaks when using custom OCIO configuration Also fix some missing color spaces when loading some OCIO configurations, by falling back to scene linear if role is not found. There can still be some errors in the console, need to check this further. http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management#OpenColorIO_Configuration --- intern/opencolorio/ocio_capi.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'intern') diff --git a/intern/opencolorio/ocio_capi.cpp b/intern/opencolorio/ocio_capi.cpp index d67cea61836..2fa66e5d2f5 100644 --- a/intern/opencolorio/ocio_capi.cpp +++ b/intern/opencolorio/ocio_capi.cpp @@ -47,13 +47,13 @@ #endif #define MEM_NEW(type) new(MEM_mallocN(sizeof(type), __func__)) type() -#define MEM_DELETE(what, type) { what->~type(); MEM_freeN(what); } (void)0 +#define MEM_DELETE(what, type) if(what) { what->~type(); MEM_freeN(what); } (void)0 static void OCIO_reportError(const char *err) { std::cerr << "OpenColorIO Error: " << err << std::endl; - OCIO_abort(); + // OCIO_abort(); } static void OCIO_reportException(Exception &exception) @@ -75,6 +75,8 @@ ConstConfigRcPtr *OCIO_getCurrentConfig(void) OCIO_reportException(exception); } + MEM_DELETE(config, ConstConfigRcPtr); + return NULL; } @@ -107,6 +109,8 @@ ConstConfigRcPtr *OCIO_configCreateFromEnv(void) OCIO_reportException(exception); } + MEM_DELETE(config, ConstConfigRcPtr); + return NULL; } @@ -125,6 +129,8 @@ ConstConfigRcPtr *OCIO_configCreateFromFile(const char *filename) OCIO_reportException(exception); } + MEM_DELETE(config, ConstConfigRcPtr); + return NULL; } @@ -169,9 +175,10 @@ ConstColorSpaceRcPtr *OCIO_configGetColorSpace(ConstConfigRcPtr *config, const c } catch (Exception &exception) { OCIO_reportException(exception); - MEM_DELETE(cs, ConstColorSpaceRcPtr); } + MEM_DELETE(cs, ConstColorSpaceRcPtr); + return NULL; } @@ -314,6 +321,8 @@ ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(ConstConfigRcPtr *config, OCIO_reportException(exception); } + MEM_DELETE(p, ConstProcessorRcPtr); + return 0; } @@ -331,6 +340,8 @@ ConstProcessorRcPtr *OCIO_configGetProcessor(ConstConfigRcPtr *config, ConstTran OCIO_reportException(exception); } + MEM_DELETE(p, ConstProcessorRcPtr); + return NULL; } -- cgit v1.2.3