Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix (harmless) Coverity warnings
  • Loading branch information
nyalldawson committed Feb 12, 2016
1 parent 3567191 commit 9e2890d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/core/qgsunittypes.cpp
Expand Up @@ -157,13 +157,14 @@ double QgsUnitTypes::fromUnitToUnitFactor( QGis::UnitType fromUnit, QGis::UnitTy
#define NMILE_TO_METER 1852.0

// Unify degree units
// remove for QGIS 3.0, as extra degree types will be removed
if ( fromUnit == QGis::DecimalDegrees || fromUnit == QGis::DegreesMinutesSeconds || fromUnit == QGis::DegreesDecimalMinutes )
fromUnit = QGis::Degrees;
if ( toUnit == QGis::DecimalDegrees || toUnit == QGis::DegreesMinutesSeconds || toUnit == QGis::DegreesDecimalMinutes )
toUnit = QGis::Degrees;

// Calculate the conversion factor between the specified units
if ( fromUnit != toUnit && fromUnit != QGis::UnknownUnit && toUnit != QGis::UnknownUnit )
if ( fromUnit != toUnit )
{
switch ( fromUnit )
{
Expand Down Expand Up @@ -217,8 +218,6 @@ QString QgsUnitTypes::encodeUnit( QgsSymbolV2::OutputUnit unit )
default:
return "MM";
}
//avoid warning
return QString();
}

QgsSymbolV2::OutputUnit QgsUnitTypes::decodeSymbolUnit( const QString& string, bool* ok )
Expand Down
12 changes: 6 additions & 6 deletions tests/src/core/testqgsmaptopixelgeometrysimplifier.cpp
Expand Up @@ -108,34 +108,34 @@ void TestQgsMapToPixelGeometrySimplifier::cleanup()

void TestQgsMapToPixelGeometrySimplifier::testDefaultGeometry()
{
QgsGeometry *g = new QgsGeometry();
QScopedPointer< QgsGeometry > g( new QgsGeometry() );
int fl = QgsMapToPixelSimplifier::SimplifyGeometry;
bool ret = QgsMapToPixelSimplifier::simplifyGeometry( g, fl, 10.0 );
bool ret = QgsMapToPixelSimplifier::simplifyGeometry( g.data(), fl, 10.0 );
QVERIFY( ! ret ); // not simplifiable
}

void TestQgsMapToPixelGeometrySimplifier::testLine1()
{
// NOTE: we need more than 4 vertices, or the line will not be
// reduced at all by the algorithm
QgsGeometry *g = QgsGeometry::fromWkt( "LINESTRING(0 0,1 1,2 0,3 1,4 0,20 1,20 0,10 0,5 0)" );
QScopedPointer< QgsGeometry > g( QgsGeometry::fromWkt( "LINESTRING(0 0,1 1,2 0,3 1,4 0,20 1,20 0,10 0,5 0)" ) );
int fl;
bool ret;
QString wkt;

fl = QgsMapToPixelSimplifier::SimplifyGeometry;
ret = QgsMapToPixelSimplifier::simplifyGeometry( g, fl, 10.0 );
ret = QgsMapToPixelSimplifier::simplifyGeometry( g.data(), fl, 10.0 );
QVERIFY( ret );
wkt = g->exportToWkt();
// NOTE: I don't think vertex 1,1 should be in this result,
// but that's what we get now
QCOMPARE( wkt, QString( "LineString (0 0, 1 1, 20 1, 10 0, 5 0)" ) );

fl = QgsMapToPixelSimplifier::SimplifyEnvelope;
ret = QgsMapToPixelSimplifier::simplifyGeometry( g, fl, 20.0 );
ret = QgsMapToPixelSimplifier::simplifyGeometry( g.data(), fl, 20.0 );
QVERIFY( ! ret );

ret = QgsMapToPixelSimplifier::simplifyGeometry( g, fl, 30.0 );
ret = QgsMapToPixelSimplifier::simplifyGeometry( g.data(), fl, 30.0 );
QVERIFY( ret );
wkt = g->exportToWkt();
// NOTE: I don't understand this result either
Expand Down
3 changes: 2 additions & 1 deletion tests/src/gui/testqgsfieldexpressionwidget.cpp
Expand Up @@ -36,7 +36,8 @@ class TestQgsFieldExpressionWidget : public QObject

public:
TestQgsFieldExpressionWidget()
: mLayerA( nullptr )
: mWidget( nullptr )
, mLayerA( nullptr )
, mLayerB( nullptr )
{}

Expand Down

0 comments on commit 9e2890d

Please sign in to comment.