Merge pull request #3504 from Beep6581/fix-clang-warnings

Fix some Clang warnings reported by @Partha1b
This commit is contained in:
Floessie
2016-11-10 18:21:19 +01:00
committed by GitHub
3 changed files with 35 additions and 14 deletions

View File

@@ -22,6 +22,7 @@
#include <vector>
#include <cstdio>
#include <cmath>
#include <type_traits>
#include <glibmm.h>
#include <lcms2.h>
@@ -206,7 +207,7 @@ public:
}
}*/
Threshold<T> & operator= (const Threshold<T> &rhs)
Threshold<T>& operator =(const Threshold<T> &rhs)
{
value[0] = rhs.value[0];
value[1] = rhs.value[1];
@@ -217,16 +218,34 @@ public:
return *this;
}
bool operator== (const Threshold<T> &rhs) const
template<typename U = T>
typename std::enable_if<std::is_floating_point<U>::value, bool>::type operator ==(const Threshold<U> &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::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::fabs(value[0] - rhs.value[0]) < 1e-10
&& std::fabs(value[1] - rhs.value[1]) < 1e-10;
}
}
template<typename U = T>
typename std::enable_if<std::is_integral<U>::value, bool>::type operator ==(const Threshold<U> &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];
}
}
};

View File

@@ -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);
}

View File

@@ -17,9 +17,11 @@
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cassert>
#include <cmath>
#include "thresholdselector.h"
#include "multilangmgr.h"
#include <cassert>
#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;
}
}