From 25c67ab3c16a9a5a79f4d904d0a451e84562875f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Tue, 8 Nov 2016 20:23:48 +0100 Subject: [PATCH 1/4] Fix some Clang warnings reported by @Partha1b --- rtgui/exifpanel.cc | 2 +- rtgui/thresholdselector.cc | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/rtgui/exifpanel.cc b/rtgui/exifpanel.cc index 88d0a062b..2decd48eb 100644 --- a/rtgui/exifpanel.cc +++ b/rtgui/exifpanel.cc @@ -430,7 +430,7 @@ void ExifPanel::addPressed () } else { tcombo->set_active_text (sel); - if (tcombo->get_active () < 0) { + if (!tcombo->get_active ()) { tcombo->append_text (sel); tcombo->set_active_text (sel); } diff --git a/rtgui/thresholdselector.cc b/rtgui/thresholdselector.cc index 34d5bf14a..59320dd2a 100644 --- a/rtgui/thresholdselector.cc +++ b/rtgui/thresholdselector.cc @@ -17,9 +17,11 @@ * along with RawTherapee. If not, see . */ +#include +#include + #include "thresholdselector.h" #include "multilangmgr.h" -#include #include "mycurve.h" ThresholdSelector::ThresholdSelector(double minValueBottom, double maxValueBottom, double defBottom, Glib::ustring labelBottom, unsigned int precisionBottom, @@ -551,7 +553,7 @@ void ThresholdSelector::findLitCursor(int posX, int posY) // we use minValTop since if this block is executed, it means that we are in a simple Threshold where both bottom and top range are the same double cursorX = (posX - hb) * (maxValTop - minValTop) / (w - 2 * hb) + minValTop; - if (cursorX > positions[TS_TOPRIGHT] || abs(cursorX - positions[TS_TOPRIGHT]) < abs(cursorX - positions[TS_TOPLEFT])) { + if (cursorX > positions[TS_TOPRIGHT] || std::fabs(cursorX - positions[TS_TOPRIGHT]) < std::fabs(cursorX - positions[TS_TOPLEFT])) { litCursor = TS_TOPRIGHT; } } @@ -564,7 +566,7 @@ void ThresholdSelector::findLitCursor(int posX, int posY) // we use minValTop since if this block is executed, it means that we are in a simple Threshold where both bottom and top range are the same double cursorX = (posX - hb) * (maxValTop - minValTop) / (w - 2 * hb) + minValTop; - if (cursorX > positions[TS_BOTTOMRIGHT] || abs(cursorX - positions[TS_BOTTOMRIGHT]) < abs(cursorX - positions[TS_BOTTOMLEFT])) { + if (cursorX > positions[TS_BOTTOMRIGHT] || std::fabs(cursorX - positions[TS_BOTTOMRIGHT]) < std::fabs(cursorX - positions[TS_BOTTOMLEFT])) { litCursor = TS_BOTTOMRIGHT; } } From 4ee191487e0d6357cee593be57bddf5ce814c715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Wed, 9 Nov 2016 19:28:14 +0100 Subject: [PATCH 2/4] Fix uncritical warnings in `rtengine/procparams.h` --- rtengine/procparams.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/rtengine/procparams.h b/rtengine/procparams.h index c65e89e24..3a7c3efbb 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -206,7 +206,7 @@ public: } }*/ - Threshold & operator= (const Threshold &rhs) + Threshold& operator =(const Threshold &rhs) { value[0] = rhs.value[0]; value[1] = rhs.value[1]; @@ -217,16 +217,17 @@ public: return *this; } - bool operator== (const Threshold &rhs) const + bool operator ==(const Threshold &rhs) const { - if (_isDouble) - return fabs(value[0] - rhs.value[0]) < 1e-10 - && fabs(value[1] - rhs.value[1]) < 1e-10 - && fabs(value[2] - rhs.value[2]) < 1e-10 - && fabs(value[3] - rhs.value[3]) < 1e-10; - else - return fabs(value[0] - rhs.value[0]) < 1e-10 - && fabs(value[1] - rhs.value[1]) < 1e-10; + if (_isDouble) { + return std::abs(value[0] - rhs.value[0]) < 1e-10 + && std::abs(value[1] - rhs.value[1]) < 1e-10 + && std::abs(value[2] - rhs.value[2]) < 1e-10 + && std::abs(value[3] - rhs.value[3]) < 1e-10; + } else { + return std::abs(value[0] - rhs.value[0]) < 1e-10 + && std::abs(value[1] - rhs.value[1]) < 1e-10; + } } }; From b3bc325934ff412ff740d35c1984bcd987e1929c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Wed, 9 Nov 2016 20:57:23 +0100 Subject: [PATCH 3/4] Add integral `Threshold::operator ==(Threshold)` Kudos to @heckflosse for reminding me what C++11 is about. :) --- rtengine/procparams.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 3a7c3efbb..868a56540 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -229,6 +230,22 @@ public: && std::abs(value[1] - rhs.value[1]) < 1e-10; } } + + template::value>::type> + bool operator ==(const Threshold &rhs) const + { + if (_isDouble) { + return + value[0] == rhs.value[0] + && value[1] == rhs.value[1] + && value[2] == rhs.value[2] + && value[3] == rhs.value[3]; + } else { + return + value[0] == rhs.value[0] + && value[1] == rhs.value[1]; + } + } }; /** From 2d743bfe7f9c5e4e520e3be7f9df39225b2deb53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Thu, 10 Nov 2016 18:04:06 +0100 Subject: [PATCH 4/4] Provide a better `std::enable_if<>` solution --- rtengine/procparams.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/rtengine/procparams.h b/rtengine/procparams.h index 868a56540..7c2d71aaa 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -218,21 +218,22 @@ public: return *this; } - bool operator ==(const Threshold &rhs) const + template + typename std::enable_if::value, bool>::type operator ==(const Threshold &rhs) const { if (_isDouble) { - return std::abs(value[0] - rhs.value[0]) < 1e-10 - && std::abs(value[1] - rhs.value[1]) < 1e-10 - && std::abs(value[2] - rhs.value[2]) < 1e-10 - && std::abs(value[3] - rhs.value[3]) < 1e-10; + return std::fabs(value[0] - rhs.value[0]) < 1e-10 + && std::fabs(value[1] - rhs.value[1]) < 1e-10 + && std::fabs(value[2] - rhs.value[2]) < 1e-10 + && std::fabs(value[3] - rhs.value[3]) < 1e-10; } else { - return std::abs(value[0] - rhs.value[0]) < 1e-10 - && std::abs(value[1] - rhs.value[1]) < 1e-10; + return std::fabs(value[0] - rhs.value[0]) < 1e-10 + && std::fabs(value[1] - rhs.value[1]) < 1e-10; } } - template::value>::type> - bool operator ==(const Threshold &rhs) const + template + typename std::enable_if::value, bool>::type operator ==(const Threshold &rhs) const { if (_isDouble) { return