Skip to content
Permalink
Browse files
cppcheck fixes
  • Loading branch information
jef-n committed May 16, 2016
1 parent ee533a7 commit b514f52
Show file tree
Hide file tree
Showing 43 changed files with 63 additions and 77 deletions.
@@ -462,12 +462,12 @@ int DualEdgeTriangulation::baseEdgeOfPoint( int point )
return actedge;
}

else if ( leftofnumber <= 0 )
else if ( leftofnumber <= 0.0 )
{
actedge = mHalfEdge[actedge]->getNext();
}

else if ( leftofnumber > 0 )
else
{
actedge = mHalfEdge[mHalfEdge[mHalfEdge[mHalfEdge[actedge]->getDual()]->getNext()]->getNext()]->getDual();
}
@@ -248,9 +248,8 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx
bool foundFieldThatCanBeExportedAsDisplayedValue = false;
for ( int i = 0; i < mLayer->fields().size(); ++i )
{
QgsEditorWidgetFactory *factory;
if ( mLayer->editFormConfig()->widgetType( i ) != "TextEdit" &&
( factory = QgsEditorWidgetRegistry::instance()->factory( mLayer->editFormConfig()->widgetType( i ) ) ) )
QgsEditorWidgetRegistry::instance()->factory( mLayer->editFormConfig()->widgetType( i ) ) )
{
foundFieldThatCanBeExportedAsDisplayedValue = true;
break;
@@ -141,7 +141,6 @@ void QgsMapToolFillRing::cadCanvasReleaseEvent( QgsMapMouseEvent * e )
QgsFeatureIterator fit = vlayer->getFeatures( QgsFeatureRequest().setFilterFid( modifiedFid ) );

QgsFeature f;
bool res = false;
if ( fit.nextFeature( f ) )
{
//create QgsFeature with wkb representation
@@ -150,6 +149,7 @@ void QgsMapToolFillRing::cadCanvasReleaseEvent( QgsMapMouseEvent * e )
ft->setGeometry( QgsGeometry::fromPolygon( QgsPolygon() << pointList.toVector() ) );
ft->setAttributes( f.attributes() );

bool res = false;
if ( QApplication::keyboardModifiers() == Qt::ControlModifier )
{
res = vlayer->addFeature( *ft );
@@ -170,7 +170,6 @@ void QgsMapToolFillRing::cadCanvasReleaseEvent( QgsMapMouseEvent * e )
delete ft;
vlayer->destroyEditCommand();
}
res = false;
}
}
stopCapturing();
@@ -836,7 +836,7 @@ void QgsComposerMap::setNewAtlasFeatureExtent( const QgsRectangle& extent )
newExtent.setYMinimum( extent.yMinimum() - deltaHeight / 2 );
newExtent.setYMaximum( extent.yMaximum() + deltaHeight / 2 );
}
else if ( currentWidthHeightRatio >= newWidthHeightRatio )
else
{
//enlarge width of new extent, ensuring the map center stays the same
double newWidth = currentWidthHeightRatio * newExtent.height();
@@ -35,7 +35,7 @@ class QgsInternalGeometryEngine
* for the whole lifetime of this object.
* @param geometry
*/
QgsInternalGeometryEngine( const QgsGeometry& geometry );
explicit QgsInternalGeometryEngine( const QgsGeometry& geometry );

/**
* Will extrude a line or (segmentized) curve by a given offset and return a polygon
@@ -189,7 +189,7 @@ class QextSerialPort: public QIODevice
EventDriven
};

QextSerialPort(QueryMode mode = EventDriven);
explicit QextSerialPort(QueryMode mode = EventDriven);
QextSerialPort(const QString & name, QueryMode mode = EventDriven);
QextSerialPort(PortSettings const& s, QueryMode mode = EventDriven);
QextSerialPort(const QString & name, PortSettings const& s, QueryMode mode = EventDriven);
@@ -296,7 +296,7 @@ template<class Object> class QgsSignalBlocker
/** Constructor for QgsSignalBlocker
* @param object QObject to block signals from
*/
QgsSignalBlocker( Object* object )
explicit QgsSignalBlocker( Object* object )
: mObject( object )
, mPreviousState( object->blockSignals( true ) )
{}
@@ -349,6 +349,7 @@ class CORE_EXPORT QgsApplication : public QApplication
/** Get maximum concurrent thread count
* @note added in 2.4 */
static int maxThreads() { return ABISYM( mMaxThreads ); }

/** Set maximum concurrent thread count
* @note must be between 1 and \#cores, -1 means use all available cores
* @note added in 2.4 */
@@ -47,6 +47,7 @@ class QgsExpressionPrivate
: ref( 1 )
, mRootNode( other.mRootNode ? other.mRootNode->clone() : nullptr )
, mParserErrorString( other.mParserErrorString )
, mEvalErrorString( other.mEvalErrorString )
, mRowNumber( 0 )
, mScale( other.mScale )
, mExp( other.mExp )
@@ -23,7 +23,7 @@
class QgsExpressionSorter
{
public:
QgsExpressionSorter( const QList<QgsFeatureRequest::OrderByClause>& preparedOrderBys )
explicit QgsExpressionSorter( const QList<QgsFeatureRequest::OrderByClause>& preparedOrderBys )
: mPreparedOrderBys( preparedOrderBys )
{}

@@ -37,7 +37,7 @@ class QgsLabelSorter
{
public:

QgsLabelSorter( const QgsMapSettings& mapSettings )
explicit QgsLabelSorter( const QgsMapSettings& mapSettings )
: mMapSettings( mapSettings )
{}

@@ -284,7 +284,7 @@ void QgsLayerDefinition::DependencySorter::init( const QDomDocument& doc )
}
else
{
it++;
++it;
}
}
}
@@ -81,13 +81,13 @@ class QgsNetworkDiskCache : public QNetworkDiskCache
virtual qint64 expire() override;

private:
QgsNetworkDiskCache( QObject *parent );
explicit QgsNetworkDiskCache( QObject *parent );
Q_DISABLE_COPY( QgsNetworkDiskCache )

class ExpirableNetworkDiskCache : public QNetworkDiskCache
{
public:
ExpirableNetworkDiskCache( QObject *parent = 0 ) : QNetworkDiskCache( parent ) {}
explicit ExpirableNetworkDiskCache( QObject *parent = 0 ) : QNetworkDiskCache( parent ) {}
qint64 runExpire() { return QNetworkDiskCache::expire(); }
};

@@ -4758,7 +4758,7 @@ void QgsPalLabeling::drawLabelBackground( QgsRenderContext& context,
// add buffer to greatest dimension of label
if ( labelWidth >= labelHeight )
sizeOut = labelWidth;
else if ( labelHeight > labelWidth )
else
sizeOut = labelHeight;

// label size in map units, convert to shapeSizeUnits, if different
@@ -30,20 +30,15 @@ using namespace SpatialIndex;

static SpatialIndex::Point point2point( const QgsPoint& point )
{
double plow[2];
plow[0] = point.x();
plow[1] = point.y();
double plow[2] = { point.x(), point.y() };
return Point( plow, 2 );
}


static SpatialIndex::Region rect2region( const QgsRectangle& rect )
{
double pLow[2], pHigh[2];
pLow[0] = rect.xMinimum();
pLow[1] = rect.yMinimum();
pHigh[0] = rect.xMaximum();
pHigh[1] = rect.yMaximum();
double pLow[2] = { rect.xMinimum(), rect.yMinimum() };
double pHigh[2] = { rect.xMaximum(), rect.yMaximum() };
return SpatialIndex::Region( pLow, pHigh, 2 );
}

@@ -357,7 +352,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry *geom, co
double prevx = 0.0, prevy = 0.0;
for ( int index = 0; index < nPoints; ++index )
{
double thisx, thisy;
double thisx = 0.0, thisy = 0.0;
wkbPtr >> thisx >> thisy;
if ( hasZValue )
wkbPtr += sizeof( double );
@@ -396,7 +391,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry *geom, co
double prevx = 0.0, prevy = 0.0;
for ( int pointnr = 0; pointnr < nPoints; ++pointnr )
{
double thisx, thisy;
double thisx = 0.0, thisy = 0.0;
wkbPtr >> thisx >> thisy;
if ( hasZValue )
wkbPtr += sizeof( double );
@@ -437,7 +432,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry *geom, co
double prevx = 0.0, prevy = 0.0;
for ( int pointnr = 0; pointnr < nPoints; ++pointnr )//loop over points in a ring
{
double thisx, thisy;
double thisx = 0.0, thisy = 0.0;
wkbPtr >> thisx >> thisy;
if ( hasZValue )
wkbPtr += sizeof( double );
@@ -482,7 +477,7 @@ static QgsPointLocator::MatchList _geometrySegmentsInRect( QgsGeometry *geom, co
double prevx = 0.0, prevy = 0.0;
for ( int pointnr = 0; pointnr < nPoints; ++pointnr )
{
double thisx, thisy;
double thisx = 0.0, thisy = 0.0;
wkbPtr >> thisx >> thisy;
if ( hasZValue )
wkbPtr += sizeof( double );
@@ -326,7 +326,7 @@ struct QgsProject::Imp
QFile file; // current physical project file
QgsPropertyKey properties_; // property hierarchy
QString title; // project title
bool autoTransaction; // transaction grouped editing
bool autoTransaction; // transaction grouped editing
bool dirty; // project has been modified since it has been read or saved

Imp()
@@ -245,7 +245,6 @@ class CORE_EXPORT QgsPropertyKey : public QgsProperty
return setValue( name(), value );
}


void dump( int tabs = 0 ) const override;

bool readXML( QDomNode & keyNode ) override;
@@ -244,11 +244,8 @@ QgsSpatialIndex& QgsSpatialIndex::operator=( const QgsSpatialIndex & other )

SpatialIndex::Region QgsSpatialIndex::rectToRegion( const QgsRectangle& rect )
{
double pt1[2], pt2[2];
pt1[0] = rect.xMinimum();
pt1[1] = rect.yMinimum();
pt2[0] = rect.xMaximum();
pt2[1] = rect.yMaximum();
double pt1[2] = { rect.xMinimum(), rect.yMinimum() },
pt2[2] = { rect.xMaximum(), rect.yMaximum() };
return SpatialIndex::Region( pt1, pt2, 2 );
}

@@ -324,9 +321,7 @@ QList<QgsFeatureId> QgsSpatialIndex::nearestNeighbor( const QgsPoint& point, int
QList<QgsFeatureId> list;
QgisVisitor visitor( list );

double pt[2];
pt[0] = point.x();
pt[1] = point.y();
double pt[2] = { point.x(), point.y() };
Point p( pt, 2 );

d->mRTree->nearestNeighborQuery( neighbors, p, visitor );
@@ -87,6 +87,8 @@ double closestSegment( const QgsPolyline& pl, const QgsPoint& pt, int& vertexAft
/** Simple graph structure for shortest path search */
struct QgsTracerGraph
{
QgsTracerGraph() : joinedVertices(0) {}

struct E // bidirectional edge
{
//! vertices that the edge connects
@@ -120,7 +122,7 @@ struct QgsTracerGraph

QgsTracerGraph* makeGraph( const QVector<QgsPolyline>& edges )
{
QgsTracerGraph* g = new QgsTracerGraph;
QgsTracerGraph *g = new QgsTracerGraph();
g->joinedVertices = 0;
QHash<QgsPoint, int> point2vertex;

@@ -2516,9 +2516,7 @@ QMap<QString, QString> QgsVectorFileWriter::ogrDriverList()
// http://lists.osgeo.org/pipermail/gdal-dev/2012-November/034580.html
// -> test if creation failes
QString option = "SPATIALITE=YES";
char **options = new char *[2];
options[0] = CPLStrdup( option.toLocal8Bit().constData() );
options[1] = nullptr;
char *options[2] = { CPLStrdup( option.toLocal8Bit().constData() ), nullptr };
OGRSFDriverH poDriver;
QgsApplication::registerOgrDrivers();
poDriver = OGRGetDriverByName( drvName.toLocal8Bit().constData() );
@@ -2533,7 +2531,6 @@ QMap<QString, QString> QgsVectorFileWriter::ogrDriverList()
}
}
CPLFree( options[0] );
delete [] options;
}
else if ( drvName == "ESRI Shapefile" )
{
@@ -706,7 +706,7 @@ class QgsVectorLayerInterruptionCheckerDuringCountSymbolFeatures: public QgsInte
public:

/** Constructor */
QgsVectorLayerInterruptionCheckerDuringCountSymbolFeatures( QProgressDialog* dialog )
explicit QgsVectorLayerInterruptionCheckerDuringCountSymbolFeatures( QProgressDialog* dialog )
: mDialog( dialog )
{
}
@@ -51,7 +51,7 @@ class QgsVectorLayerRendererInterruptionChecker: public QgsInterruptionChecker
{
public:
/** Constructor */
QgsVectorLayerRendererInterruptionChecker( const QgsRenderContext& context );
explicit QgsVectorLayerRendererInterruptionChecker( const QgsRenderContext& context );
bool mustStop() const override;
private:
const QgsRenderContext& mContext;
@@ -50,7 +50,7 @@ class QgsCaseInsensitiveLexerSQL: public QsciLexerSQL
{
public:
//! constructor
QgsCaseInsensitiveLexerSQL( QObject *parent = 0 ) : QsciLexerSQL( parent ) {}
explicit QgsCaseInsensitiveLexerSQL( QObject *parent = 0 ) : QsciLexerSQL( parent ) {}

bool caseSensitive() const override { return false; }
};
@@ -1073,7 +1073,7 @@ void QgsColorRampWidget::paintEvent( QPaintEvent *event )
}
}
}
else if ( mComponent == QgsColorWidget::Alpha )
else
{
//alpha ramps are drawn differently
//start with the checkboard pattern
@@ -196,7 +196,6 @@ void QgsDb2FeatureIterator::BuildStatement( const QgsFeatureRequest& request )
mStatement += " WHERE (" + compiler.result() + ')';
else
mStatement += " AND (" + compiler.result() + ')';
filterAdded = true;

//if only partial success when compiling expression, we need to double-check results using QGIS' expressions
mExpressionCompiled = ( result == QgsSqlExpressionCompiler::Complete );
@@ -27,12 +27,12 @@ QgsDb2GeometryColumns::QgsDb2GeometryColumns( const QSqlDatabase db )
{
QgsDebugMsg( "constructing" );
}

QgsDb2GeometryColumns::~QgsDb2GeometryColumns( )
{
mQuery.clear();
}


int QgsDb2GeometryColumns::open()
{
return open( QString(), QString() );
@@ -31,7 +31,7 @@ static const int ENV_LUW = 1, ENV_ZOS = 2;
class QgsDb2GeometryColumns
{
public:
QgsDb2GeometryColumns( const QSqlDatabase db );
explicit QgsDb2GeometryColumns( const QSqlDatabase db );

~QgsDb2GeometryColumns();

@@ -50,4 +50,4 @@ class QgsDb2GeometryColumns

};

#endif
#endif
@@ -27,6 +27,7 @@

QgsDelimitedTextFeatureIterator::QgsDelimitedTextFeatureIterator( QgsDelimitedTextFeatureSource* source, bool ownSource, const QgsFeatureRequest& request )
: QgsAbstractFeatureIteratorFromSource<QgsDelimitedTextFeatureSource>( source, ownSource, request )
, mNextId( 0 )
, mTestGeometryExact( false )
{

@@ -27,6 +27,7 @@

QgsGPXFeatureIterator::QgsGPXFeatureIterator( QgsGPXFeatureSource* source, bool ownSource, const QgsFeatureRequest& request )
: QgsAbstractFeatureIteratorFromSource<QgsGPXFeatureSource>( source, ownSource, request )
, mFetchedFid( false )
{
rewind();
}

0 comments on commit b514f52

Please sign in to comment.