From 0eb3969279f25cef60e442d7f7139894b4e31c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Tue, 21 Nov 2017 18:11:26 +0100 Subject: [PATCH] Make `PartialProfile` non-copyable --- rtengine/procparams.cc | 10 ++++++++++ rtengine/procparams.h | 36 ++++++++++++++---------------------- rtgui/filebrowser.cc | 4 ++-- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index 150dbbb70..a7a9686ef 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -4427,6 +4427,16 @@ void PartialProfile::applyTo(ProcParams* destParams) const } } +AutoPartialProfile::AutoPartialProfile() : + PartialProfile(true) +{ +} + +AutoPartialProfile::~AutoPartialProfile() +{ + deleteInstance(); +} + } } diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 44f0268c5..7ec39d3cf 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -28,6 +28,7 @@ #include "coord.h" #include "LUT.h" +#include "noncopyable.h" class ParamsEdited; @@ -1307,7 +1308,6 @@ private: * @return Error code (=0 if no error) * */ int write(const Glib::ustring& fname, const Glib::ustring& content) const; - }; /** @@ -1319,26 +1319,21 @@ private: * and hence is not responsible of their destructions. The function that instanciate * PartialProfile object has to handle all this itself. */ -class PartialProfile +class PartialProfile : + public NonCopyable { 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); + void deleteInstance(); + void clearGeneral(); + int load(const Glib::ustring& fName); + void set(bool v); + void applyTo(ProcParams* destParams) const ; + rtengine::procparams::ProcParams* pparams; ParamsEdited* pedited; - PartialProfile& operator =(const PartialProfile& rhs) - { - pparams = rhs.pparams; - pedited = rhs.pedited; - return *this; - }; - - PartialProfile (bool createInstance = false, bool paramsEditedValue = false); - PartialProfile (ProcParams* pp, ParamsEdited* pe = nullptr, bool fullCopy = false); - PartialProfile (const ProcParams* pp, const ParamsEdited* pe = nullptr); - void deleteInstance (); - void clearGeneral (); - int load (const Glib::ustring& fName); - void set (bool v); - void applyTo (ProcParams *destParams) const ; }; /** @@ -1350,11 +1345,8 @@ class AutoPartialProfile : public PartialProfile { public: - AutoPartialProfile() : PartialProfile (true) {} - ~AutoPartialProfile() - { - deleteInstance(); - } + AutoPartialProfile(); + ~AutoPartialProfile(); }; } diff --git a/rtgui/filebrowser.cc b/rtgui/filebrowser.cc index cda737285..b308911a7 100644 --- a/rtgui/filebrowser.cc +++ b/rtgui/filebrowser.cc @@ -1021,7 +1021,7 @@ void FileBrowser::pasteProfile () for (unsigned int i = 0; i < mselected.size(); i++) { // copying read only clipboard PartialProfile to a temporary one - rtengine::procparams::PartialProfile cbPartProf = clipboard.getPartialProfile(); + const rtengine::procparams::PartialProfile& cbPartProf = clipboard.getPartialProfile(); rtengine::procparams::PartialProfile pastedPartProf(cbPartProf.pparams, cbPartProf.pedited, true); // applying the PartialProfile to the thumb's ProcParams @@ -1069,7 +1069,7 @@ void FileBrowser::partPasteProfile () for (unsigned int i = 0; i < mselected.size(); i++) { // copying read only clipboard PartialProfile to a temporary one, initialized to the thumb's ProcParams mselected[i]->thumbnail->createProcParamsForUpdate(false, false); // this can execute customprofilebuilder to generate param file - rtengine::procparams::PartialProfile cbPartProf = clipboard.getPartialProfile(); + const rtengine::procparams::PartialProfile& cbPartProf = clipboard.getPartialProfile(); rtengine::procparams::PartialProfile pastedPartProf(&mselected[i]->thumbnail->getProcParams (), nullptr); // pushing the selected values of the clipboard PartialProfile to the temporary PartialProfile