diff --git a/rtengine/EdgePreservingDecomposition.cc b/rtengine/EdgePreservingDecomposition.cc index 8c1ca56a7..5e91eae9d 100644 --- a/rtengine/EdgePreservingDecomposition.cc +++ b/rtengine/EdgePreservingDecomposition.cc @@ -6,7 +6,6 @@ #endif #include "sleef.c" #include "opthelper.h" - #define pow_F(a,b) (xexpf(b*xlogf(a))) #define DIAGONALS 5 @@ -883,7 +882,7 @@ float *EdgePreservingDecomposition::CreateIteratedBlur(float *Source, float Scal return Blur; } -SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Source, float Scale, float EdgeStopping, float CompressionExponent, float DetailBoost, int Iterates, int Reweightings, float *Compressed) +SSEFUNCTION void EdgePreservingDecomposition::CompressDynamicRange(float *Source, float Scale, float EdgeStopping, float CompressionExponent, float DetailBoost, int Iterates, int Reweightings) { if(w < 300 && h < 300) { // set number of Reweightings to zero for small images (thumbnails). We could try to find a better solution here. Reweightings = 0; @@ -926,12 +925,7 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour //Blur. Also setup memory for Compressed (we can just use u since each element of u is used in one calculation). float *u = CreateIteratedBlur(Source, Scale, EdgeStopping, Iterates, Reweightings); - if(Compressed == nullptr) { - Compressed = u; - } - //Apply compression, detail boost, unlogging. Compression is done on the logged data and detail boost on unlogged. -// float temp = CompressionExponent - 1.0f; float temp; if(DetailBoost > 0.f) { @@ -958,8 +952,7 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour cev = xexpf(LVFU(Source[i]) + LVFU(u[i]) * (tempv)) - epsv; uev = xexpf(LVFU(u[i])) - epsv; sourcev = xexpf(LVFU(Source[i])) - epsv; - _mm_storeu_ps( &Source[i], sourcev); - _mm_storeu_ps( &Compressed[i], cev + DetailBoostv * (sourcev - uev) ); + _mm_storeu_ps( &Source[i], cev + DetailBoostv * (sourcev - uev) ); } } @@ -967,7 +960,7 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour float ce = xexpf(Source[i] + u[i] * (temp)) - eps; float ue = xexpf(u[i]) - eps; Source[i] = xexpf(Source[i]) - eps; - Compressed[i] = ce + DetailBoost * (Source[i] - ue); + Source[i] = ce + DetailBoost * (Source[i] - ue); } #else @@ -979,16 +972,11 @@ SSEFUNCTION float *EdgePreservingDecomposition::CompressDynamicRange(float *Sour float ce = xexpf(Source[i] + u[i] * (temp)) - eps; float ue = xexpf(u[i]) - eps; Source[i] = xexpf(Source[i]) - eps; - Compressed[i] = ce + DetailBoost * (Source[i] - ue); + Source[i] = ce + DetailBoost * (Source[i] - ue); } #endif - if(Compressed != u) { - delete[] u; - } - - return Compressed; - + delete[] u; } diff --git a/rtengine/EdgePreservingDecomposition.h b/rtengine/EdgePreservingDecomposition.h index bf567f103..1eca7b2c8 100644 --- a/rtengine/EdgePreservingDecomposition.h +++ b/rtengine/EdgePreservingDecomposition.h @@ -152,7 +152,7 @@ public: the more compression is applied, with Compression = 1 giving no effect and above 1 the opposite effect. You can totally use Compression = 1 and play with DetailBoost for some really sweet unsharp masking. If working on luma/grey, consider giving it a logarithm. In place calculation to save memory (Source == Compressed) is totally ok. Reweightings > 0 invokes CreateIteratedBlur instead of CreateBlur. */ - float *CompressDynamicRange(float *Source, float Scale = 1.0f, float EdgeStopping = 1.4f, float CompressionExponent = 0.8f, float DetailBoost = 0.1f, int Iterates = 20, int Reweightings = 0, float *Compressed = nullptr); + void CompressDynamicRange(float *Source, float Scale = 1.0f, float EdgeStopping = 1.4f, float CompressionExponent = 0.8f, float DetailBoost = 0.1f, int Iterates = 20, int Reweightings = 0); private: MultiDiagonalSymmetricMatrix *A; //The equations are simple enough to not mandate a matrix class, but fast solution NEEDS a complicated preconditioner. diff --git a/rtengine/array2D.h b/rtengine/array2D.h index c05c739dc..9645a3a6e 100644 --- a/rtengine/array2D.h +++ b/rtengine/array2D.h @@ -113,7 +113,7 @@ public: // use as empty declaration, resize before use! // very useful as a member object array2D() : - x(0), y(0), owner(0), flags(0), ptr(nullptr), data(nullptr), lock(0) + x(0), y(0), owner(0), flags(0), ptr(nullptr), data(nullptr), lock(false) { //printf("got empty array2D init\n"); } @@ -143,7 +143,7 @@ public: { flags = flgs; //if (lock) { printf("array2D attempt to overwrite data\n");raise(SIGSEGV);} - lock |= flags & ARRAY2D_LOCK_DATA; + lock = flags & ARRAY2D_LOCK_DATA; // when by reference // TODO: improve this code with ar_realloc() owner = (flags & ARRAY2D_BYREFERENCE) ? 0 : 1; diff --git a/rtengine/camconst.cc b/rtengine/camconst.cc index 2449a1cd1..5a051bfa2 100644 --- a/rtengine/camconst.cc +++ b/rtengine/camconst.cc @@ -27,9 +27,6 @@ CameraConst::CameraConst() white_max = 0; } -CameraConst::~CameraConst() -{ -} bool CameraConst::parseApertureScaling(CameraConst *cc, void *ji_) @@ -317,6 +314,7 @@ CameraConst::parseEntry(void *cJSON_, const char *make_model) return cc; parse_error: + delete cc; return nullptr; } @@ -709,6 +707,14 @@ CameraConstantsStore::CameraConstantsStore() { } + +CameraConstantsStore::~CameraConstantsStore() +{ + for (auto &p : mCameraConstants) { + delete p.second; + } +} + void CameraConstantsStore::init(Glib::ustring baseDir, Glib::ustring userSettingsDir) { parse_camera_constants_file(Glib::build_filename(baseDir, "camconst.json")); diff --git a/rtengine/camconst.h b/rtengine/camconst.h index 713936bf8..31b65f3e8 100644 --- a/rtengine/camconst.h +++ b/rtengine/camconst.h @@ -26,7 +26,6 @@ private: std::map mApertureScaling; CameraConst(); - ~CameraConst(); static bool parseLevels(CameraConst *cc, int bw, void *ji); static bool parseApertureScaling(CameraConst *cc, void *ji); bool get_Levels(struct camera_const_levels & lvl, int bw, int iso, float fnumber); @@ -55,6 +54,7 @@ private: bool parse_camera_constants_file(Glib::ustring filename); public: + ~CameraConstantsStore(); void init(Glib::ustring baseDir, Glib::ustring userSettingsDir); static CameraConstantsStore *getInstance(void); CameraConst *get(const char make[], const char model[]); diff --git a/rtengine/color.cc b/rtengine/color.cc index f045a84d9..0da74d1c0 100644 --- a/rtengine/color.cc +++ b/rtengine/color.cc @@ -773,37 +773,38 @@ void Color::hsl2rgb01 (float h, float s, float l, float &r, float &g, float &b) void Color::rgb2hsv(float r, float g, float b, float &h, float &s, float &v) { - double var_R = r / 65535.0; - double var_G = g / 65535.0; - double var_B = b / 65535.0; + const double var_R = r / 65535.0; + const double var_G = g / 65535.0; + const double var_B = b / 65535.0; - double var_Min = min(var_R, var_G, var_B); - double var_Max = max(var_R, var_G, var_B); - double del_Max = var_Max - var_Min; + const double var_Min = min(var_R, var_G, var_B); + const double var_Max = max(var_R, var_G, var_B); + const double del_Max = var_Max - var_Min; + + h = 0.f; v = var_Max; if (del_Max < 0.00001 && del_Max > -0.00001) { // no fabs, slow! - h = 0; - s = 0; + s = 0.f; } else { s = del_Max / var_Max; - if ( var_R == var_Max ) { + if (var_R == var_Max) { h = (var_G - var_B) / del_Max; - } else if ( var_G == var_Max ) { + } else if (var_G == var_Max) { h = 2.0 + (var_B - var_R) / del_Max; - } else if ( var_B == var_Max ) { + } else if (var_B == var_Max) { h = 4.0 + (var_R - var_G) / del_Max; } - h /= 6.0; + h /= 6.f; - if ( h < 0 ) { - h += 1; + if (h < 0.f) { + h += 1.f; } - if ( h > 1 ) { - h -= 1; + if (h > 1.f) { + h -= 1.f; } } } diff --git a/rtengine/dcp.cc b/rtengine/dcp.cc index ad0621ce0..62765f812 100644 --- a/rtengine/dcp.cc +++ b/rtengine/dcp.cc @@ -1701,6 +1701,15 @@ DCPStore* DCPStore::getInstance() return &instance; } + +DCPStore::~DCPStore() +{ + for (auto &p : profile_cache) { + delete p.second; + } +} + + void DCPStore::init(const Glib::ustring& rt_profile_dir, bool loadAll) { MyMutex::MyLock lock(mutex); diff --git a/rtengine/dcp.h b/rtengine/dcp.h index 5a6858099..10bbf8f7e 100644 --- a/rtengine/dcp.h +++ b/rtengine/dcp.h @@ -152,6 +152,7 @@ class DCPStore final : public NonCopyable { public: + ~DCPStore(); static DCPStore* getInstance(); void init(const Glib::ustring& rt_profile_dir, bool loadAll = true); diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index cc2f402c9..3a455c7a2 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -406,12 +406,8 @@ void Crop::update (int todo) MyTime t1aue, t2aue; t1aue.set(); - int crW, crH; - - if (settings->leveldnv == 0) { - crW = 100; - crH = 100; - } + int crW = 100; // settings->leveldnv == 0 + int crH = 100; // settings->leveldnv == 0 if (settings->leveldnv == 1) { crW = 250; @@ -1633,7 +1629,7 @@ bool Crop::setCropSizes (int rcx, int rcy, int rcw, int rch, int skip, bool inte parent->ipf.transCoord (parent->fw, parent->fh, bx1, by1, bw, bh, orx, ory, orw, orh); - if (check_need_larger_crop_for_lcp_distortion (parent->fw, parent->fh, orx, ory, orw, orh, parent->params)) { + if (check_need_larger_crop_for_lcp_distortion(parent->fw, parent->fh, orx, ory, orw, orh, parent->params)) { // TODO - this is an estimate of the max distortion relative to the image size. ATM it is hardcoded to be 15%, which seems enough. If not, need to revise int dW = int (double (parent->fw) * 0.15 / (2 * skip)); int dH = int (double (parent->fh) * 0.15 / (2 * skip)); diff --git a/rtengine/iccstore.cc b/rtengine/iccstore.cc index 3bcc8515e..47bfadd80 100644 --- a/rtengine/iccstore.cc +++ b/rtengine/iccstore.cc @@ -276,6 +276,31 @@ public: } } + ~Implementation() + { + for (auto &p : wProfiles) { + if (p.second) { + cmsCloseProfile(p.second); + } + } + for (auto &p : wProfilesGamma) { + if (p.second) { + cmsCloseProfile(p.second); + } + } + for (auto &p : fileProfiles) { + if(p.second) { + cmsCloseProfile(p.second); + } + } + if(srgb) { + cmsCloseProfile(srgb); + } + if(xyz) { + cmsCloseProfile(xyz); + } + } + void init(const Glib::ustring& usrICCDir, const Glib::ustring& rtICCDir, bool loadAll) { // Reads all profiles from the given profiles dir diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 97dc47748..d8163ccd4 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -6443,7 +6443,7 @@ void ImProcFunctions::EPDToneMapCIE (CieImage *ncie, float a_w, float c_, float //Jacques Desmis : always Iterates=5 for compatibility images between preview and output - epd.CompressDynamicRange (Qpr, (float)sca / skip, (float)edgest, Compression, DetailBoost, Iterates, rew, Qpr); + epd.CompressDynamicRange (Qpr, (float)sca / skip, (float)edgest, Compression, DetailBoost, Iterates, rew); //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. float s = (1.0f + 38.7889f) * powf (Compression, 1.5856f) / (1.0f + 38.7889f * powf (Compression, 1.5856f)); @@ -6577,7 +6577,7 @@ void ImProcFunctions::EPDToneMaplocal (LabImage *lab, LabImage *tmp1, unsigned i fwrite(L, N, sizeof(float), f); fclose(f);*/ - epd.CompressDynamicRange (L, sca / float (skip), edgest, Compression, DetailBoost, Iterates, rew, L); + epd.CompressDynamicRange (L, sca / float (skip), edgest, Compression, DetailBoost, Iterates, rew); //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. float s = (1.0f + 38.7889f) * powf (Compression, 1.5856f) / (1.0f + 38.7889f * powf (Compression, 1.5856f)); @@ -6693,7 +6693,7 @@ void ImProcFunctions::EPDToneMap (LabImage *lab, unsigned int Iterates, int skip fwrite(L, N, sizeof(float), f); fclose(f);*/ - epd.CompressDynamicRange (L, sca / float (skip), edgest, Compression, DetailBoost, Iterates, rew, L); + epd.CompressDynamicRange (L, sca / float (skip), edgest, Compression, DetailBoost, Iterates, rew); //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. float s = (1.0f + 38.7889f) * powf (Compression, 1.5856f) / (1.0f + 38.7889f * powf (Compression, 1.5856f)); diff --git a/rtengine/ipretinex.cc b/rtengine/ipretinex.cc index 3a4538c3e..6516d4b73 100644 --- a/rtengine/ipretinex.cc +++ b/rtengine/ipretinex.cc @@ -273,8 +273,9 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float ** } } - float varx = 0.f; - float limdx, ilimdx; + float varx = vart; + float limdx = limD; + float ilimdx = ilimD; if (gradvart != 0) { if (gradvart == 1) { @@ -294,10 +295,6 @@ void RawImageSource::MSR (float** luminance, float** originalLuminance, float ** limdx = limD * (0.4f * it + 0.6f); ilimdx = 1.f / limdx; } - } else { - varx = vart; - limdx = limD; - ilimdx = ilimD; } scal = round (sc); diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index 65da843d2..0f1e693ec 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -1253,7 +1253,8 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet (LabImage * lab, LabImage * dst, in delete [] meanN; delete [] sigma; delete [] sigmaN; - + delete [] MaxP; + delete [] MaxN; } #ifdef _RT_NESTED_OPENMP omp_set_nested (oldNested); @@ -1653,7 +1654,7 @@ void ImProcFunctions::EPDToneMapResid (float * WavCoeffs_L0, unsigned int Itera } - epd2.CompressDynamicRange (WavCoeffs_L0, (float)sca / skip, edgest, Compression, DetailBoost, Iterates, rew, WavCoeffs_L0); + epd2.CompressDynamicRange(WavCoeffs_L0, (float)sca / skip, edgest, Compression, DetailBoost, Iterates, rew); //Restore past range, also desaturate a bit per Mantiuk's Color correction for tone mapping. #ifdef _RT_NESTED_OPENMP diff --git a/rtengine/lcp.cc b/rtengine/lcp.cc index 821194afe..e198948ba 100644 --- a/rtengine/lcp.cc +++ b/rtengine/lcp.cc @@ -361,6 +361,11 @@ SSEFUNCTION void LCPMapper::processVignetteLine3Channels(int width, int y, float LCPProfile::LCPProfile(const Glib::ustring &fname) { + for (int i = 0; i < MaxPersModelCount; i++) { + aPersModel[i] = nullptr; + } + pCurPersModel = nullptr; + const int BufferSize = 8192; char buf[BufferSize]; @@ -378,10 +383,6 @@ LCPProfile::LCPProfile(const Glib::ustring &fname) isFisheye = inCamProfiles = firstLIDone = inPerspect = inAlternateLensID = inAlternateLensNames = false; sensorFormatFactor = 1; - for (int i = 0; i < MaxPersModelCount; i++) { - aPersModel[i] = nullptr; - } - persModelCount = 0; *inInvalidTag = 0; @@ -412,6 +413,19 @@ LCPProfile::LCPProfile(const Glib::ustring &fname) filterBadFrames(1.5, 100); } + +LCPProfile::~LCPProfile() +{ + if (pCurPersModel) { + delete pCurPersModel; + } + for (int i = 0; i < MaxPersModelCount; i++) { + if (aPersModel[i]) { + delete aPersModel[i]; + } + } +} + // from all frames not marked as bad already, take average and filter out frames with higher deviation than this if there are enough values int LCPProfile::filterBadFrames(double maxAvgDevFac, int minFramesLeft) { @@ -737,7 +751,7 @@ void XMLCALL LCPProfile::XmlTextHandler(void *pLCPProfile, const XML_Char *s, in if (!pProf->inCamProfiles || pProf->inAlternateLensID || pProf->inAlternateLensNames || *pProf->inInvalidTag) { return; } - + for (int i = 0; i < len; ++i) { pProf->textbuf << s[i]; } @@ -746,8 +760,6 @@ void XMLCALL LCPProfile::XmlTextHandler(void *pLCPProfile, const XML_Char *s, in void LCPProfile::handle_text(std::string text) { - const char *raw = text.c_str(); - // Check if it contains non-whitespaces (there are several calls to this for one tag unfortunately) bool onlyWhiteSpace = true; for (size_t i = 0; i < text.size(); ++i) { @@ -766,6 +778,8 @@ void LCPProfile::handle_text(std::string text) // convert to null terminated char* tag = pProf->lastTag; + const char* raw = text.c_str(); + // Common data section if (!pProf->firstLIDone) { // Generic tags are the same for all @@ -886,6 +900,15 @@ LCPStore* LCPStore::getInstance() return &instance_; } + +LCPStore::~LCPStore() +{ + for (auto &p : profileCache) { + delete p.second; + } +} + + LCPProfile* LCPStore::getProfile (Glib::ustring filename) { if (filename.length() == 0 || !isValidLCPFileName(filename)) { diff --git a/rtengine/lcp.h b/rtengine/lcp.h index 8cfcd5694..f7164117f 100644 --- a/rtengine/lcp.h +++ b/rtengine/lcp.h @@ -110,6 +110,7 @@ public: LCPPersModel* aPersModel[MaxPersModelCount]; // Do NOT use std::list or something, it's buggy in GCC! explicit LCPProfile(const Glib::ustring &fname); + ~LCPProfile(); void calcParams(int mode, float focalLength, float focusDist, float aperture, LCPModelCommon *pCorr1, LCPModelCommon *pCorr2, LCPModelCommon *pCorr3) const; // Interpolates between the persModels frames @@ -124,6 +125,7 @@ class LCPStore std::map profileCache; public: + ~LCPStore(); Glib::ustring getDefaultCommonDirectory() const; bool isValidLCPFileName(Glib::ustring filename) const; LCPProfile* getProfile(Glib::ustring filename); diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 26752947d..27b3c32a9 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -9636,20 +9636,25 @@ PartialProfile::PartialProfile (bool createInstance, bool paramsEditedValue) pparams = nullptr; pedited = nullptr; } + ownsPparams = ownsPedited = true; } PartialProfile::PartialProfile (ProcParams* pp, ParamsEdited* pe, bool fullCopy) { if (fullCopy && pp) { - pparams = new ProcParams (*pp); + pparams = new ProcParams(*pp); + ownsPparams = true; } else { pparams = pp; + ownsPparams = false; } if (fullCopy && pe) { - pedited = new ParamsEdited (*pe); + pedited = new ParamsEdited(*pe); + ownsPedited = true; } else { pedited = pe; + ownsPedited = false; } } @@ -9666,6 +9671,15 @@ PartialProfile::PartialProfile (const ProcParams* pp, const ParamsEdited* pe) } else { pedited = nullptr; } + ownsPparams = ownsPedited = true; +} + +PartialProfile::~PartialProfile() +{ + if(ownsPparams) + delete pparams; + if(ownsPedited) + delete pedited; } int PartialProfile::load (const Glib::ustring &fName) diff --git a/rtengine/procparams.h b/rtengine/procparams.h index e9cf691ce..f7efb6823 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -1538,11 +1538,15 @@ public: PartialProfile (bool createInstance = false, bool paramsEditedValue = false); PartialProfile (ProcParams* pp, ParamsEdited* pe = nullptr, bool fullCopy = false); PartialProfile (const ProcParams* pp, const ParamsEdited* pe = nullptr); + ~PartialProfile (); void deleteInstance (); void clearGeneral (); int load (const Glib::ustring &fName); void set (bool v); const void applyTo (ProcParams *destParams) const ; +private: + bool ownsPparams; + bool ownsPedited; }; /** diff --git a/rtengine/profilestore.cc b/rtengine/profilestore.cc index 12c1cca5c..75e916808 100644 --- a/rtengine/profilestore.cc +++ b/rtengine/profilestore.cc @@ -248,6 +248,8 @@ bool ProfileStore::parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath if (!fileFound && (level > 0 || displayLevel0)) { // no files found in this level, we delete the subdirectory entry folders.pop_back(); + + delete entries.back(); entries.pop_back(); } diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 61e95c1a9..b8e0ada03 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -279,12 +279,8 @@ private: if (settings->leveldnautsimpl == 1 && params.dirpyrDenoise.Cmethod == "PON") { MyTime t1pone, t2pone; t1pone.set(); - int crW, crH; - - if (settings->leveldnv == 0) { - crW = 100; - crH = 100; - } + int crW = 100; // settings->leveldnv == 0 + int crH = 100; // settings->leveldnv == 0 if (settings->leveldnv == 1) { crW = 250; @@ -748,7 +744,7 @@ private: { procparams::ProcParams& params = job->pparams; //ImProcFunctions ipf (¶ms, true); - ImProcFunctions &ipf = * (ipf_p.get()); + ImProcFunctions &ipf = *(ipf_p.get()); // perform luma/chroma denoise // CieImage *cieView; @@ -813,7 +809,7 @@ private: { procparams::ProcParams& params = job->pparams; //ImProcFunctions ipf (¶ms, true); - ImProcFunctions &ipf = * (ipf_p.get()); + ImProcFunctions &ipf = *(ipf_p.get()); imgsrc->convertColorSpace (baseImg, params.icm, currWB); @@ -836,7 +832,7 @@ private: { procparams::ProcParams& params = job->pparams; //ImProcFunctions ipf (¶ms, true); - ImProcFunctions &ipf = * (ipf_p.get()); + ImProcFunctions &ipf = *(ipf_p.get()); if (params.dirpyrequalizer.cbdlMethod == "bef" && params.dirpyrequalizer.enabled && !params.colorappearance.enabled) { const int W = baseImg->getWidth(); @@ -2064,7 +2060,7 @@ private: { procparams::ProcParams& params = job->pparams; //ImProcFunctions ipf (¶ms, true); - ImProcFunctions &ipf = * (ipf_p.get()); + ImProcFunctions &ipf = *(ipf_p.get()); int imw, imh; double scale_factor = ipf.resizeScale (¶ms, fw, fh, imw, imh); @@ -2100,7 +2096,7 @@ private: tmplab = std::move (resized); } - adjust_procparams (scale_factor); + adjust_procparams(scale_factor); fw = imw; fh = imh; @@ -2154,7 +2150,7 @@ private: } } } - + params.epd.scale *= scale_factor; //params.epd.edgeStopping *= scale_factor; diff --git a/rtgui/cropwindow.cc b/rtgui/cropwindow.cc index 25311b97b..d7a2f5740 100644 --- a/rtgui/cropwindow.cc +++ b/rtgui/cropwindow.cc @@ -1026,6 +1026,12 @@ void CropWindow::pointerMoved (int bstate, int x, int y) cropHandler.cimg.lock (); int vx = x - xpos - imgX; int vy = y - ypos - imgY; + + if(decorated) { + vx -= sideBorderWidth; + vy -= (titleHeight + upperBorderWidth + sepWidth); + } + // guint8* pix = cropHandler.cropPixbuf->get_pixels() + vy*cropHandler.cropPixbuf->get_rowstride() + vx*3; // if (vx < cropHandler.cropPixbuf->get_width() && vy < cropHandler.cropPixbuf->get_height()) // pmlistener->pointerMoved (true, mx, my, pix[0], pix[1], pix[2]); diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index 459abbe5b..b67fef8bd 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -451,7 +451,7 @@ public: }; EditorPanel::EditorPanel (FilePanel* filePanel) - : catalogPane(nullptr), realized(false), iHistoryShow(nullptr), iHistoryHide(nullptr), iTopPanel_1_Show(nullptr), iTopPanel_1_Hide(nullptr), iRightPanel_1_Show(nullptr), iRightPanel_1_Hide(nullptr), iBeforeLockON(nullptr), iBeforeLockOFF(nullptr), beforePreviewHandler(nullptr), beforeIarea(nullptr), beforeBox(nullptr), afterBox(nullptr), afterHeaderBox(nullptr), parent(nullptr), openThm(nullptr), ipc(nullptr), beforeIpc(nullptr), isProcessing(false) + : catalogPane(nullptr), realized(false), tbBeforeLock(nullptr), iHistoryShow(nullptr), iHistoryHide(nullptr), iTopPanel_1_Show(nullptr), iTopPanel_1_Hide(nullptr), iRightPanel_1_Show(nullptr), iRightPanel_1_Hide(nullptr), iBeforeLockON(nullptr), iBeforeLockOFF(nullptr), previewHandler(nullptr), beforePreviewHandler(nullptr), beforeIarea(nullptr), beforeBox(nullptr), afterBox(nullptr), beforeLabel(nullptr), afterLabel(nullptr), beforeHeaderBox(nullptr), afterHeaderBox(nullptr), parent(nullptr), openThm(nullptr), isrc(nullptr), ipc(nullptr), beforeIpc(nullptr), err(0), isProcessing(false) { epih = new EditorPanelIdleHelper; @@ -1689,6 +1689,8 @@ bool EditorPanel::idle_saveImage (ProgressConnector *pc, Gl else if (sf.format == "jpg") ld->startFunc (sigc::bind (sigc::mem_fun (img, &rtengine::IImage16::saveAsJPEG), fname, sf.jpegQuality, sf.jpegSubSamp), sigc::bind (sigc::mem_fun (*this, &EditorPanel::idle_imageSaved), ld, img, fname, sf)); + else + delete ld; } else { Glib::ustring msg_ = Glib::ustring ("") + fname + ": Error during image processing\n"; Gtk::MessageDialog msgd (*parent, msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); diff --git a/rtgui/filebrowser.cc b/rtgui/filebrowser.cc index dd37a740b..b4238f011 100644 --- a/rtgui/filebrowser.cc +++ b/rtgui/filebrowser.cc @@ -128,11 +128,7 @@ void findOriginalEntries (const std::vector& entries) FileBrowser::FileBrowser () : tbl(nullptr), numFiltered(0) { - - fbih = new FileBrowserIdleHelper; - fbih->fbrowser = this; - fbih->destroyed = false; - fbih->pending = 0; + session_id_ = 0; ProfileStore::getInstance()->addListener(this); @@ -546,37 +542,27 @@ void FileBrowser::doubleClicked (ThumbBrowserEntryBase* entry) void FileBrowser::addEntry (FileBrowserEntry* entry) { struct addparams { - FileBrowserIdleHelper* fbih; - FileBrowserEntry* entry; + FileBrowser *browser; + FileBrowserEntry *entry; + unsigned int session_id; }; - fbih->pending++; - entry->setParent (this); addparams* const ap = new addparams; - ap->fbih = fbih; + entry->setParent (this); + ap->browser = this; ap->entry = entry; + ap->session_id = session_id(); const auto func = [](gpointer data) -> gboolean { addparams* const ap = static_cast(data); - FileBrowserIdleHelper* fbih = ap->fbih; - - if (fbih->destroyed) { - if (fbih->pending == 1) { - delete fbih; - } else { - fbih->pending--; - } - + if (ap->session_id != ap->browser->session_id()) { delete ap->entry; delete ap; - - return 0; + } else { + ap->browser->addEntry_(ap->entry); + delete ap; } - ap->fbih->fbrowser->addEntry_ (ap->entry); - delete ap; - fbih->pending--; - return FALSE; }; @@ -653,16 +639,7 @@ FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname) void FileBrowser::close () { - if (fbih->pending) { - fbih->destroyed = true; - } else { - delete fbih; - } - - fbih = new FileBrowserIdleHelper; - fbih->fbrowser = this; - fbih->destroyed = false; - fbih->pending = 0; + ++session_id_; { MYWRITERLOCK(l, entryRW); diff --git a/rtgui/filebrowser.h b/rtgui/filebrowser.h index 4bad832eb..4efdb7219 100644 --- a/rtgui/filebrowser.h +++ b/rtgui/filebrowser.h @@ -53,12 +53,6 @@ public: } }; -struct FileBrowserIdleHelper { - FileBrowser* fbrowser; - bool destroyed; - int pending; -}; - /* * Class handling actions common to all thumbnails of the file browser */ @@ -71,6 +65,7 @@ private: typedef sigc::signal type_trash_changed; IdleRegister idle_register; + unsigned int session_id_; protected: Gtk::MenuItem* rank[6]; @@ -129,7 +124,6 @@ protected: FileBrowserListener* tbl; BrowserFilter filter; int numFiltered; - FileBrowserIdleHelper* fbih; void toTrashRequested (std::vector tbe); void fromTrashRequested (std::vector tbe); @@ -152,6 +146,8 @@ public: FileBrowserEntry* delEntry (const Glib::ustring& fname); // return the entry if found here return NULL otherwise void close (); + unsigned int session_id() const { return session_id_; } + void setBatchPParamsChangeListener (BatchPParamsChangeListener* l) { bppcl = l; diff --git a/rtgui/filecatalog.cc b/rtgui/filecatalog.cc index 4ac1e0a3d..710450d90 100644 --- a/rtgui/filecatalog.cc +++ b/rtgui/filecatalog.cc @@ -720,6 +720,7 @@ void FileCatalog::previewReady (int dir_id, FileBrowserEntry* fdn) { if ( dir_id != selectedDirectoryId ) { + delete fdn; return; } diff --git a/rtgui/main-cli.cc b/rtgui/main-cli.cc index 2a2afca63..f6df47119 100644 --- a/rtgui/main-cli.cc +++ b/rtgui/main-cli.cc @@ -115,12 +115,12 @@ int main(int argc, char **argv) // get the path where the rawtherapee executable is stored #ifdef WIN32 WCHAR exnameU[512] = {0}; - GetModuleFileNameW (NULL, exnameU, 512); - WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 512, 0, 0 ); + GetModuleFileNameW (NULL, exnameU, 511); + WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 511, 0, 0 ); #else - if (readlink("/proc/self/exe", exname, 512) < 0) { - strncpy(exname, argv[0], 512); + if (readlink("/proc/self/exe", exname, 511) < 0) { + strncpy(exname, argv[0], 511); } #endif diff --git a/rtgui/main.cc b/rtgui/main.cc index c7d9d4134..7c4aaa6c3 100644 --- a/rtgui/main.cc +++ b/rtgui/main.cc @@ -137,12 +137,12 @@ int main (int argc, char **argv) // get the path where the rawtherapee executable is stored #ifdef WIN32 WCHAR exnameU[512] = {0}; - GetModuleFileNameW (NULL, exnameU, 512); - WideCharToMultiByte (CP_UTF8, 0, exnameU, -1, exname, 512, 0, 0 ); + GetModuleFileNameW (NULL, exnameU, 511); + WideCharToMultiByte(CP_UTF8, 0, exnameU, -1, exname, 511, 0, 0 ); #else - if (readlink ("/proc/self/exe", exname, 512) < 0) { - strncpy (exname, argv[0], 512); + if (readlink("/proc/self/exe", exname, 511) < 0) { + strncpy(exname, argv[0], 511); } #endif diff --git a/rtgui/options.cc b/rtgui/options.cc index 195514258..554882839 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -584,22 +584,26 @@ void Options::setDefaults () 0, // ADDSET_DIRPYREQ_THRESHOLD 0, // ADDSET_DIRPYREQ_SKINPROTECT 0, // ADDSET_COLORTONING_SPLIT + 0, // ADDSET_COLORTONING_SATTHRESHOLD + 0, // ADDSET_COLORTONING_SATOPACITY + 0, // ADDSET_COLORTONING_BALANCE + 0, // ADDSET_COLORTONING_STRENGTH 0, // ADDSET_DIRPYRDN_PASSES 0, // ADDSET_RAWFFCLIPCONTROL 0, // ADDSET_FILMSIMULATION_STRENGTH 0, // ADDSET_WA + 0, // ADDSET_WA_SKINPROTECT + 0, // ADDSET_WA_THRESHOLD2 + 0, // ADDSET_WA_THRR + 0, // ADDSET_WA_THRRH 0, // ADDSET_WA_THRESHOLD 0, // ADDSET_WA_THRESHOLD2 - 0, // ADDSET_WA_THRES 0, // ADDSET_WA_CHRO 0, // ADDSET_WA_CHROMA 0, // ADDSET_WA_CONTRAST - 0, // ADDSET_WA_SKINPROTECT - 0, // ADDSET_WA_RESCHRO 0, // ADDSET_WA_RESCON 0, // ADDSET_WA_RESCONH - 0, // ADDSET_WA_THRR - 0, // ADDSET_WA_THRRH + 0, // ADDSET_WA_RESCHRO 0, // ADDSET_WA_SKYPROTECT 0, // ADDSET_WA_EDGRAD 0, // ADDSET_WA_EDGVAL diff --git a/rtgui/previewloader.cc b/rtgui/previewloader.cc index 0c0ecf9f6..a43c47d2e 100644 --- a/rtgui/previewloader.cc +++ b/rtgui/previewloader.cc @@ -168,6 +168,11 @@ PreviewLoader::PreviewLoader(): { } +PreviewLoader::~PreviewLoader() +{ + delete impl_; +} + PreviewLoader* PreviewLoader::getInstance() { static PreviewLoader instance_; diff --git a/rtgui/previewloader.h b/rtgui/previewloader.h index d5207cd44..d2f21b013 100644 --- a/rtgui/previewloader.h +++ b/rtgui/previewloader.h @@ -88,6 +88,7 @@ public: private: PreviewLoader(); + ~PreviewLoader(); class Impl; Impl* impl_; diff --git a/rtgui/profilepanel.cc b/rtgui/profilepanel.cc index 7947eebf3..09f5ec71a 100644 --- a/rtgui/profilepanel.cc +++ b/rtgui/profilepanel.cc @@ -39,7 +39,7 @@ void ProfilePanel::cleanup () delete partialProfileDlg; } -ProfilePanel::ProfilePanel () : storedPProfile(nullptr), lastFilename(""), imagePath("") +ProfilePanel::ProfilePanel () : storedPProfile(nullptr), lastFilename(""), imagePath(""), lastSavedPSE(nullptr), customPSE(nullptr) { tpc = nullptr; @@ -128,6 +128,8 @@ ProfilePanel::~ProfilePanel () delete profileFillModeOnImage; delete profileFillModeOffImage; + delete lastSavedPSE; + delete customPSE; } bool ProfilePanel::isCustomSelected() @@ -164,14 +166,24 @@ Gtk::TreeIter ProfilePanel::getLastSavedRow() Gtk::TreeIter ProfilePanel::addCustomRow() { - const ProfileStoreEntry *customPSE = new ProfileStoreEntry(Glib::ustring ("(" + M("PROFILEPANEL_PCUSTOM") + ")"), PSET_FILE, 0, 0); + if(customPSE) { + delete customPSE; + customPSE = nullptr; + } + + customPSE = new ProfileStoreEntry(Glib::ustring ("(" + M("PROFILEPANEL_PCUSTOM") + ")"), PSET_FILE, 0, 0); Gtk::TreeIter newEntry = profiles->addRow(customPSE); return newEntry; } Gtk::TreeIter ProfilePanel::addLastSavedRow() { - const ProfileStoreEntry *lastSavedPSE = new ProfileStoreEntry(Glib::ustring ("(" + M("PROFILEPANEL_PLASTSAVED") + ")"), PSET_FILE, 0, 0); + if(lastSavedPSE) { + delete lastSavedPSE; + lastSavedPSE = nullptr; + } + + lastSavedPSE = new ProfileStoreEntry(Glib::ustring ("(" + M("PROFILEPANEL_PLASTSAVED") + ")"), PSET_FILE, 0, 0); Gtk::TreeIter newEntry = profiles->addRow(lastSavedPSE); return newEntry; } diff --git a/rtgui/profilepanel.h b/rtgui/profilepanel.h index 72c9db36b..ddd7133ca 100644 --- a/rtgui/profilepanel.h +++ b/rtgui/profilepanel.h @@ -42,6 +42,8 @@ private: RTImage *profileFillModeOffImage; Gtk::ToggleButton* fillMode; Gtk::TreeIter currRow; + ProfileStoreEntry *lastSavedPSE; + ProfileStoreEntry *customPSE; void profileFillModeToggled (); bool isCustomSelected (); diff --git a/rtgui/thumbimageupdater.cc b/rtgui/thumbimageupdater.cc index 95618d5ab..b30047c2f 100644 --- a/rtgui/thumbimageupdater.cc +++ b/rtgui/thumbimageupdater.cc @@ -184,6 +184,11 @@ ThumbImageUpdater::ThumbImageUpdater(): { } +ThumbImageUpdater::~ThumbImageUpdater() +{ + delete impl_; +} + void ThumbImageUpdater::add(ThumbBrowserEntryBase* tbe, bool* priority, bool upgrade, ThumbImageUpdateListener* l) { diff --git a/rtgui/thumbimageupdater.h b/rtgui/thumbimageupdater.h index 3b34c9456..0ac92a31a 100644 --- a/rtgui/thumbimageupdater.h +++ b/rtgui/thumbimageupdater.h @@ -93,6 +93,7 @@ public: private: ThumbImageUpdater(); + ~ThumbImageUpdater(); class Impl; Impl* impl_;