Close OpenEXR thread pool on exit

This partially solves ASAN report about unfreed memory. There is still
something in the report, need to have a closer look with debug version
of OpenEXE library.
This commit is contained in:
Sergey Sharybin
2018-09-18 11:10:49 +02:00
parent 8b41cd5b96
commit d04eb330e8
3 changed files with 10 additions and 1 deletions

View File

@@ -74,7 +74,7 @@ const ImFileType IMB_FILE_TYPES[] = {
{NULL, NULL, imb_is_a_hdr, NULL, imb_ftype_default, imb_loadhdr, NULL, imb_savehdr, NULL, IM_FTYPE_FLOAT, IMB_FTYPE_RADHDR, COLOR_ROLE_DEFAULT_FLOAT},
#endif
#ifdef WITH_OPENEXR
{imb_initopenexr, NULL, imb_is_a_openexr, NULL, imb_ftype_default, imb_load_openexr, NULL, imb_save_openexr, NULL, IM_FTYPE_FLOAT, IMB_FTYPE_OPENEXR, COLOR_ROLE_DEFAULT_FLOAT},
{imb_initopenexr, imb_exitopenexr, imb_is_a_openexr, NULL, imb_ftype_default, imb_load_openexr, NULL, imb_save_openexr, NULL, IM_FTYPE_FLOAT, IMB_FTYPE_OPENEXR, COLOR_ROLE_DEFAULT_FLOAT},
#endif
#ifdef WITH_OPENJPEG
{NULL, NULL, imb_is_a_jp2, NULL, imb_ftype_default, imb_load_jp2, NULL, imb_save_jp2, NULL, IM_FTYPE_FLOAT, IMB_FTYPE_JP2, COLOR_ROLE_DEFAULT_BYTE},

View File

@@ -1921,4 +1921,12 @@ void imb_initopenexr(void)
setGlobalThreadCount(num_threads);
}
void imb_exitopenexr(void)
{
/* Tells OpenEXR to free thread pool, also ensures there is no running
* tasks.
*/
setGlobalThreadCount(0);
}
} // export "C"

View File

@@ -40,6 +40,7 @@ extern "C" {
#include <stdio.h>
void imb_initopenexr (void);
void imb_exitopenexr (void);
int imb_is_a_openexr (const unsigned char *mem);