Suspect comparision(?) in TRoom.cpp
Posted: Tue Jun 11, 2013 10:38 pm
I note on line 348 of the current code there are multiple comparisons which throw up multiple GCC warnings: "warning: suggest parentheses around comparison in operand of ‘==’" what are these tests supposed to be establishing - is it equality of all four variables because if I recall C/C++ expression evaluation correctly non-equal values such as min_x = -5, min_y = -4, max_x=0, max_y=1 will still cause the overall expression to be evaluated as true?That being the case wouldn't it be better to use:?
Code: Select all
void TRoom::calcRoomDimensions()
{
QMapIterator<QString, QList<QPointF> > it(customLines);
while( it.hasNext() )
{
it.next();
const QString & _e = it.key();
const QList<QPointF> & _pL= it.value();
if( _pL.size() < 1 ) continue;
if( min_x == min_y == max_x == max_y == 1 )
{
min_x = _pL[0].x();
max_x = min_x;
min_y = _pL[0].y();
max_y = min_y;
}
for( int i=0; i<_pL.size(); i++ )
{
qreal _x = _pL[i].x();
qreal _y = _pL[i].y();
if( min_x > _x )
min_x = _x;
if( max_x < _x )
max_x = _x;
if( min_y > _y )
min_y = _y;
if( max_y < _y )
max_y = _y;
}
qDebug()<<"custom lines span: x("<<min_x<<"/"<<max_x<<") y("<<min_y<<"/"<<max_y<<")";
}
}
Code: Select all
if( min_x == max_y && min_y == max_y && min_x == min_y )