diff --git a/rtengine/imageio.cc b/rtengine/imageio.cc index 59f7cf541..1f170de9a 100644 --- a/rtengine/imageio.cc +++ b/rtengine/imageio.cc @@ -909,8 +909,11 @@ int ImageIO::loadPPMFromMemory(const char* buffer, int width, int height, bool s int ImageIO::savePNG (Glib::ustring fname, int compression, volatile int bps) { + if (getW() < 1 || getH() < 1) { + return IMIO_HEADERERROR; + } - FILE *file = g_fopen_withBinaryAndLock (fname); + FILE* const file = g_fopen_withBinaryAndLock (fname); if (!file) { return IMIO_CANNOTWRITEFILE; @@ -1003,8 +1006,11 @@ int ImageIO::savePNG (Glib::ustring fname, int compression, volatile int bps) // Quality 0..100, subsampling: 1=low quality, 2=medium, 3=high int ImageIO::saveJPEG (Glib::ustring fname, int quality, int subSamp) { + if (getW() < 1 || getH() < 1) { + return IMIO_HEADERERROR; + } - FILE *file = g_fopen_withBinaryAndLock (fname); + FILE* const file = g_fopen_withBinaryAndLock (fname); if (!file) { return IMIO_CANNOTWRITEFILE; @@ -1190,6 +1196,9 @@ int ImageIO::saveJPEG (Glib::ustring fname, int quality, int subSamp) int ImageIO::saveTIFF (Glib::ustring fname, int bps, bool uncompressed) { + if (getW() < 1 || getH() < 1) { + return IMIO_HEADERERROR; + } //TODO: Handling 32 bits floating point output images! bool writeOk = true; diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index a3ea37bc1..e96d8ee2f 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -5332,7 +5332,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("Crop", "W")) { - crop.w = std::max(keyFile.get_integer ("Crop", "W"),1); + crop.w = std::max(keyFile.get_integer("Crop", "W"), 1); if (pedited) { pedited->crop.w = true; @@ -5340,7 +5340,7 @@ int ProcParams::load (const Glib::ustring &fname, ParamsEdited* pedited) } if (keyFile.has_key ("Crop", "H")) { - crop.h = std::max(keyFile.get_integer ("Crop", "H"),1); + crop.h = std::max(keyFile.get_integer("Crop", "H"), 1); if (pedited) { pedited->crop.h = true; diff --git a/rtengine/stdimagesource.cc b/rtengine/stdimagesource.cc index 601cbe89c..95475e6a4 100644 --- a/rtengine/stdimagesource.cc +++ b/rtengine/stdimagesource.cc @@ -117,22 +117,19 @@ int StdImageSource::load (const Glib::ustring &fname, bool batch) switch (sFormat) { case (IIOSF_UNSIGNED_CHAR): { - Image8 *img_8 = new Image8 (); - img = img_8; + img = new Image8; break; } case (IIOSF_UNSIGNED_SHORT): { - Image16 *img_16 = new Image16 (); - img = img_16; + img = new Image16; break; } case (IIOSF_LOGLUV24): case (IIOSF_LOGLUV32): case (IIOSF_FLOAT): { - Imagefloat *img_float = new Imagefloat (); - img = img_float; + img = new Imagefloat; break; } diff --git a/rtgui/crop.cc b/rtgui/crop.cc index bb7dfdb0a..5e7dca68a 100644 --- a/rtgui/crop.cc +++ b/rtgui/crop.cc @@ -326,10 +326,10 @@ void Crop::read (const ProcParams* pp, const ParamsEdited* pedited) guide->set_active (8); } - x->set_value (pp->crop.x); - y->set_value (pp->crop.y); - w->set_value (std::max(pp->crop.w,1)); - h->set_value (std::max(pp->crop.h,1)); + x->set_value(pp->crop.x); + y->set_value(pp->crop.y); + w->set_value(std::max(pp->crop.w, 1)); + h->set_value(std::max(pp->crop.h, 1)); nx = pp->crop.x; ny = pp->crop.y; diff --git a/rtgui/crop.h b/rtgui/crop.h index 61eff4bd7..077903836 100644 --- a/rtgui/crop.h +++ b/rtgui/crop.h @@ -27,9 +27,10 @@ class CropPanelListener { - public: - virtual void cropSelectRequested () {} + virtual ~CropPanelListener() = default; + + virtual void cropSelectRequested() = 0; }; class CropRatio @@ -42,7 +43,6 @@ public: class Crop : public ToolParamBlock, public CropGUIListener, public FoldableToolPanel, public rtengine::SizeListener { - protected: Gtk::CheckButton* fixr; MyComboBoxText* ratio; @@ -70,7 +70,6 @@ protected: std::vector cropratio; public: - Crop (); void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr); diff --git a/rtgui/profilestore.cc b/rtgui/profilestore.cc index ddb6782d4..083b45686 100644 --- a/rtgui/profilestore.cc +++ b/rtgui/profilestore.cc @@ -284,8 +284,8 @@ const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path if ( lastdot_pos != Glib::ustring::npos && lastdot_pos <= casefolded_path.size() - 4 - && !casefolded_path.compare(lastdot_pos, 4, paramFileExtension)) - { + && !casefolded_path.compare(lastdot_pos, 4, paramFileExtension) + ) { // removing the extension // now use dot position without casefold() path = path.substr(0, path.find_last_of('.'));