From ee4749f27197057b97d31056960f76af26bc5357 Mon Sep 17 00:00:00 2001 From: Hombre Date: Sun, 11 Sep 2016 03:49:33 +0200 Subject: [PATCH] Fix a recursive Mutex lock bug when selecting an output Gamma profile. --- rtengine/iccstore.cc | 6 ++++-- rtengine/iplab2rgb.cc | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rtengine/iccstore.cc b/rtengine/iccstore.cc index 13d1fbbdd..7b52a7a53 100644 --- a/rtengine/iccstore.cc +++ b/rtengine/iccstore.cc @@ -434,6 +434,7 @@ void ICCStore::getGammaArray(const procparams::ColorManagementParams &icm, Gamma } } +// WARNING: the caller must lock lcmsMutex cmsHPROFILE ICCStore::createGammaProfile (const procparams::ColorManagementParams &icm, GammaValues &ga) { float p[6]; //primaries ga[6] = 0.0; @@ -519,16 +520,17 @@ cmsHPROFILE ICCStore::createGammaProfile (const procparams::ColorManagementParam // 7 parameters for smoother curves cmsFloat64Number Parameters[7] = { ga[0], ga[1], ga[2], ga[3], ga[4], ga[5], ga[6] } ; - lcmsMutex->lock (); + //lcmsMutex->lock (); Mutex acquired by the caller cmsWhitePointFromTemp(&xyD, (double)temp); GammaTRC[0] = GammaTRC[1] = GammaTRC[2] = cmsBuildParametricToneCurve(NULL, 5, Parameters); //5 = smoother than 4 cmsHPROFILE oprofdef = cmsCreateRGBProfile(&xyD, &Primaries, GammaTRC); //oprofdef become Outputprofile cmsFreeToneCurve(GammaTRC[0]); - lcmsMutex->unlock (); + //lcmsMutex->unlock (); return oprofdef; } +// WARNING: the caller must lock lcmsMutex cmsHPROFILE ICCStore::createCustomGammaOutputProfile (const procparams::ColorManagementParams &icm, GammaValues &ga) { bool pro = false; Glib::ustring outProfile; diff --git a/rtengine/iplab2rgb.cc b/rtengine/iplab2rgb.cc index 01144b397..b82b0ca22 100644 --- a/rtengine/iplab2rgb.cc +++ b/rtengine/iplab2rgb.cc @@ -305,8 +305,10 @@ Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int cmsHPROFILE oprof = NULL; if (ga) { + lcmsMutex->lock (); iccStore->getGammaArray(icm, *ga); oprof = iccStore->createGammaProfile(icm, *ga); + lcmsMutex->unlock (); printf("iccStore->createGammaProfile(icm, *ga);\n"); } else { oprof = iccStore->getProfile (icm.output);