diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 51e0bebf9..e200ba610 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -8470,20 +8470,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); + ownsPparams = true; } else { pparams = pp; + ownsPparams = false; } if (fullCopy && pe) { pedited = new ParamsEdited(*pe); + ownsPedited = true; } else { pedited = pe; + ownsPedited = false; } } @@ -8500,12 +8505,15 @@ PartialProfile::PartialProfile(const ProcParams* pp, const ParamsEdited* pe) } else { pedited = nullptr; } + ownsPparams = ownsPedited = true; } PartialProfile::~PartialProfile() { - delete pparams; - delete pedited; + 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 5b2b2ebc4..817a4e011 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -1441,6 +1441,9 @@ public: int load (const Glib::ustring &fName); void set (bool v); const void applyTo (ProcParams *destParams) const ; +private: + bool ownsPparams; + bool ownsPedited; }; /**