Skip to content

Commit

Permalink
more coverity fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 9, 2015
1 parent 0593ef6 commit 9fb0065
Show file tree
Hide file tree
Showing 24 changed files with 152 additions and 124 deletions.
77 changes: 46 additions & 31 deletions src/analysis/interpolation/DualEdgeTriangulation.h
Expand Up @@ -66,13 +66,13 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
/**Returns a pointer to a value list with the information of the triangles surrounding (counterclockwise) a point. Four integer values describe a triangle, the first three are the number of the half edges of the triangle and the fourth is -10, if the third (and most counterclockwise) edge is a breakline, and -20 otherwise. The value list has to be deleted by the code which called the method*/
QList<int>* getSurroundingTriangles( int pointno ) override;
/**Returns the largest x-coordinate value of the bounding box*/
virtual double getXMax() const override;
virtual double getXMax() const override { return xMax; }
/**Returns the smallest x-coordinate value of the bounding box*/
virtual double getXMin() const override;
virtual double getXMin() const override { return xMin; }
/**Returns the largest y-coordinate value of the bounding box*/
virtual double getYMax() const override;
virtual double getYMax() const override { return yMax; }
/**Returns the smallest x-coordinate value of the bounding box*/
virtual double getYMin() const override;
virtual double getYMin() const override { return yMin; }
/**Returns the number of points*/
virtual int getNumberOfPoints() const override;
/**Removes the line with number i from the triangulation*/
Expand Down Expand Up @@ -180,40 +180,46 @@ class ANALYSIS_EXPORT DualEdgeTriangulation: public Triangulation
void evaluateInfluenceRegion( Point3D* point, int edge, QSet<int> &set );
};

inline DualEdgeTriangulation::DualEdgeTriangulation() : xMax( 0 ), xMin( 0 ), yMax( 0 ), yMin( 0 ), mTriangleInterpolator( 0 ), mForcedCrossBehaviour( Triangulation::DELETE_FIRST ), mEdgeColor( 0, 255, 0 ), mForcedEdgeColor( 0, 0, 255 ), mBreakEdgeColor( 100, 100, 0 ), mDecorator( this )
inline DualEdgeTriangulation::DualEdgeTriangulation()
: xMax( 0 )
, xMin( 0 )
, yMax( 0 )
, yMin( 0 )
, mTriangleInterpolator( 0 )
, mForcedCrossBehaviour( Triangulation::DELETE_FIRST )
, mEdgeColor( 0, 255, 0 )
, mForcedEdgeColor( 0, 0, 255 )
, mBreakEdgeColor( 100, 100, 0 )
, mDecorator( this )
, mEdgeInside( 0 )
, mEdgeOutside( 0 )
, mEdgeWithPoint( 0 )
, mUnstableEdge( 0 )
, mTwiceInsPoint( 0 )
{
mPointVector.reserve( mDefaultStorageForPoints );
mHalfEdge.reserve( mDefaultStorageForHalfEdges );
}

inline DualEdgeTriangulation::DualEdgeTriangulation( int nop, Triangulation* decorator ): xMax( 0 ), xMin( 0 ), yMax( 0 ), yMin( 0 ), mTriangleInterpolator( 0 ), mForcedCrossBehaviour( Triangulation::DELETE_FIRST ), mEdgeColor( 0, 255, 0 ), mForcedEdgeColor( 0, 0, 255 ), mBreakEdgeColor( 100, 100, 0 ), mDecorator( decorator )
inline DualEdgeTriangulation::DualEdgeTriangulation( int nop, Triangulation* decorator )
: xMax( 0 )
, xMin( 0 )
, yMax( 0 )
, yMin( 0 )
, mTriangleInterpolator( 0 )
, mForcedCrossBehaviour( Triangulation::DELETE_FIRST )
, mEdgeColor( 0, 255, 0 )
, mForcedEdgeColor( 0, 0, 255 )
, mBreakEdgeColor( 100, 100, 0 )
, mDecorator( decorator ? decorator : this )
, mEdgeInside( 0 )
, mEdgeOutside( 0 )
, mEdgeWithPoint( 0 )
, mUnstableEdge( 0 )
, mTwiceInsPoint( 0 )
{
mPointVector.reserve( nop );
mHalfEdge.reserve( nop );
if ( !mDecorator )
{
mDecorator = this;
}
}

inline double DualEdgeTriangulation::getXMax() const
{
return xMax;
}

inline double DualEdgeTriangulation::getXMin() const
{
return xMin;
}

inline double DualEdgeTriangulation::getYMax() const
{
return yMax;
}

inline double DualEdgeTriangulation::getYMin() const
{
return yMin;
}

inline int DualEdgeTriangulation::getNumberOfPoints() const
Expand All @@ -228,7 +234,16 @@ inline Point3D* DualEdgeTriangulation::getPoint( unsigned int i ) const

inline bool DualEdgeTriangulation::halfEdgeBBoxTest( int edge, double xlowleft, double ylowleft, double xupright, double yupright ) const
{
return (( getPoint( mHalfEdge[edge]->getPoint() )->getX() >= xlowleft && getPoint( mHalfEdge[edge]->getPoint() )->getX() <= xupright && getPoint( mHalfEdge[edge]->getPoint() )->getY() >= ylowleft && getPoint( mHalfEdge[edge]->getPoint() )->getY() <= yupright ) || ( getPoint( mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint() )->getX() >= xlowleft && getPoint( mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint() )->getX() <= xupright && getPoint( mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint() )->getY() >= ylowleft && getPoint( mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint() )->getY() <= yupright ) );
return (
( getPoint( mHalfEdge[edge]->getPoint() )->getX() >= xlowleft &&
getPoint( mHalfEdge[edge]->getPoint() )->getX() <= xupright &&
getPoint( mHalfEdge[edge]->getPoint() )->getY() >= ylowleft &&
getPoint( mHalfEdge[edge]->getPoint() )->getY() <= yupright ) ||
( getPoint( mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint() )->getX() >= xlowleft &&
getPoint( mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint() )->getX() <= xupright &&
getPoint( mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint() )->getY() >= ylowleft &&
getPoint( mHalfEdge[mHalfEdge[edge]->getDual()]->getPoint() )->getY() <= yupright )
);
}

#endif
Expand Down
3 changes: 2 additions & 1 deletion src/analysis/raster/qgsrastercalcnode.cpp
Expand Up @@ -16,7 +16,8 @@
#include <cfloat>

QgsRasterCalcNode::QgsRasterCalcNode()
: mLeft( 0 )
: mType( tNumber )
, mLeft( 0 )
, mRight( 0 )
, mNumber( 0 )
{
Expand Down
68 changes: 27 additions & 41 deletions src/app/qgisapp.cpp
Expand Up @@ -10122,7 +10122,7 @@ void QgisApp::namAuthenticationRequired( QNetworkReply *reply, QAuthenticator *a
{
QMutexLocker lock( QgsCredentials::instance()->mutex() );

do
for ( ;; )
{
bool ok = QgsCredentials::instance()->get(
QString( "%1 at %2" ).arg( auth->realm() ).arg( reply->url().host() ),
Expand All @@ -10134,27 +10134,20 @@ void QgisApp::namAuthenticationRequired( QNetworkReply *reply, QAuthenticator *a
if ( reply->isFinished() )
return;

if ( auth->user() == username && password == auth->password() )
{
if ( !password.isNull() )
{
// credentials didn't change - stored ones probably wrong? clear password and retry
QgsCredentials::instance()->put(
QString( "%1 at %2" ).arg( auth->realm() ).arg( reply->url().host() ),
username, QString::null );
continue;
}
}
else
{
// save credentials
QgsCredentials::instance()->put(
QString( "%1 at %2" ).arg( auth->realm() ).arg( reply->url().host() ),
username, password
);
}
if ( auth->user() != username || ( password != auth->password() && !password.isNull() ) )
break;

// credentials didn't change - stored ones probably wrong? clear password and retry
QgsCredentials::instance()->put(
QString( "%1 at %2" ).arg( auth->realm() ).arg( reply->url().host() ),
username, QString::null );
}
while ( 0 );

// save credentials
QgsCredentials::instance()->put(
QString( "%1 at %2" ).arg( auth->realm() ).arg( reply->url().host() ),
username, password
);
}

auth->setUser( username );
Expand All @@ -10177,7 +10170,7 @@ void QgisApp::namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthe
{
QMutexLocker lock( QgsCredentials::instance()->mutex() );

do
for ( ;; )
{
bool ok = QgsCredentials::instance()->get(
QString( "proxy %1:%2 [%3]" ).arg( proxy.hostName() ).arg( proxy.port() ).arg( auth->realm() ),
Expand All @@ -10186,26 +10179,19 @@ void QgisApp::namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthe
if ( !ok )
return;

if ( auth->user() == username && password == auth->password() )
{
if ( !password.isNull() )
{
// credentials didn't change - stored ones probably wrong? clear password and retry
QgsCredentials::instance()->put(
QString( "proxy %1:%2 [%3]" ).arg( proxy.hostName() ).arg( proxy.port() ).arg( auth->realm() ),
username, QString::null );
continue;
}
}
else
{
QgsCredentials::instance()->put(
QString( "proxy %1:%2 [%3]" ).arg( proxy.hostName() ).arg( proxy.port() ).arg( auth->realm() ),
username, password
);
}
if ( auth->user() != username || ( password != auth->password() && !password.isNull() ) )
break;

// credentials didn't change - stored ones probably wrong? clear password and retry
QgsCredentials::instance()->put(
QString( "proxy %1:%2 [%3]" ).arg( proxy.hostName() ).arg( proxy.port() ).arg( auth->realm() ),
username, QString::null );
}
while ( 0 );

QgsCredentials::instance()->put(
QString( "proxy %1:%2 [%3]" ).arg( proxy.hostName() ).arg( proxy.port() ).arg( auth->realm() ),
username, password
);
}

auth->setUser( username );
Expand Down
3 changes: 0 additions & 3 deletions src/app/qgsattributetypedialog.h
Expand Up @@ -95,9 +95,6 @@ class APP_EXPORT QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttribut
QgsVectorLayer *mLayer;
int mFieldIdx;

bool mFieldEditable;
bool mLabelOnTop;

QgsEditorWidgetConfig mWidgetV2Config;

//! Cached configuration dialog (lazy loaded)
Expand Down
7 changes: 5 additions & 2 deletions src/app/qgsfieldsproperties.cpp
Expand Up @@ -807,12 +807,15 @@ void QgsFieldsProperties::apply()
*/

QgsFieldsProperties::FieldConfig::FieldConfig()
: mButton( NULL )
: mEditable( true )
, mEditableEnabled( true )
, mLabelOnTop( false )
, mButton( 0 )
{
}

QgsFieldsProperties::FieldConfig::FieldConfig( QgsVectorLayer* layer, int idx )
: mButton( NULL )
: mButton( 0 )
{
mEditable = layer->fieldEditable( idx );
mEditableEnabled = layer->pendingFields().fieldOrigin( idx ) != QgsFields::OriginJoin
Expand Down
4 changes: 3 additions & 1 deletion src/app/qgsfieldsproperties.h
Expand Up @@ -49,11 +49,13 @@ class APP_EXPORT QgsFieldsProperties : public QWidget, private Ui_QgsFieldsPrope
};

DesignerTreeItemData()
: mType( Field )
{}

DesignerTreeItemData( Type type, const QString& name )
: mType( type )
, mName( name ) {}
, mName( name )
{}

QString name() const { return mName; }
void setName( const QString& name ) { mName = name; }
Expand Down
5 changes: 3 additions & 2 deletions src/app/qgsmaptoolpinlabels.cpp
Expand Up @@ -30,10 +30,11 @@

QgsMapToolPinLabels::QgsMapToolPinLabels( QgsMapCanvas* canvas )
: QgsMapToolLabel( canvas )
, mDragging( false )
, mShowPinned( false )
, mRubberBand( 0 )
{
mToolName = tr( "Pin labels" );
mRubberBand = 0;
mShowPinned = false;

connect( QgisApp::instance()->actionToggleEditing(), SIGNAL( triggered() ), this, SLOT( updatePinnedLabels() ) );
connect( canvas, SIGNAL( renderComplete( QPainter * ) ), this, SLOT( highlightPinnedLabels() ) );
Expand Down
26 changes: 14 additions & 12 deletions src/core/composer/qgscomposermousehandles.cpp
Expand Up @@ -30,18 +30,20 @@
#include "qgslogger.h"
#include "qgsproject.h"

QgsComposerMouseHandles::QgsComposerMouseHandles( QgsComposition *composition ) : QObject( 0 ),
QGraphicsRectItem( 0 ),
mComposition( composition ),
mGraphicsView( 0 ),
mBeginHandleWidth( 0 ),
mBeginHandleHeight( 0 ),
mResizeMoveX( 0 ),
mResizeMoveY( 0 ),
mIsDragging( false ),
mIsResizing( false ),
mHAlignSnapItem( 0 ),
mVAlignSnapItem( 0 )
QgsComposerMouseHandles::QgsComposerMouseHandles( QgsComposition *composition )
: QObject( 0 )
, QGraphicsRectItem( 0 )
, mComposition( composition )
, mGraphicsView( 0 )
, mCurrentMouseMoveAction( NoAction )
, mBeginHandleWidth( 0 )
, mBeginHandleHeight( 0 )
, mResizeMoveX( 0 )
, mResizeMoveY( 0 )
, mIsDragging( false )
, mIsResizing( false )
, mHAlignSnapItem( 0 )
, mVAlignSnapItem( 0 )
{
//listen for selection changes, and update handles accordingly
QObject::connect( mComposition, SIGNAL( selectionChanged() ), this, SLOT( selectionChanged() ) );
Expand Down
1 change: 1 addition & 0 deletions src/core/dxf/qgsdxfexport.cpp
Expand Up @@ -311,6 +311,7 @@ QgsDxfExport::QgsDxfExport()
, mSymbolLayerCounter( 0 )
, mNextHandleId( DXF_HANDSEED )
, mBlockCounter( 0 )
, mModelSpaceBR( 0 )
{
}

Expand Down
5 changes: 2 additions & 3 deletions src/core/pal/layer.h
Expand Up @@ -113,7 +113,6 @@ namespace pal
unsigned long arrangementFlags;
LabelMode mode;
bool mergeLines;
double repeatDistance;

UpsideDownLabels upsidedownLabels;

Expand Down Expand Up @@ -290,8 +289,8 @@ namespace pal
void setMergeConnectedLines( bool m ) { mergeLines = m; }
bool getMergeConnectedLines() const { return mergeLines; }

void setRepeatDistance( double distance ) { repeatDistance = distance; }
double getRepeatDistance() const { return repeatDistance; }
// void setRepeatDistance( double distance ) { repeatDistance = distance; }
// double getRepeatDistance() const { return repeatDistance; }

void setUpsidedownLabels( UpsideDownLabels ud ) { upsidedownLabels = ud; }
UpsideDownLabels getUpsidedownLabels() const { return upsidedownLabels; }
Expand Down
14 changes: 8 additions & 6 deletions src/core/pal/pointset.cpp
Expand Up @@ -90,13 +90,15 @@ namespace pal
cHull = NULL;
}

PointSet::PointSet( double x, double y )
PointSet::PointSet( double aX, double aY )
: xmin( aX ), xmax( aY )
, ymin( aX ), ymax( aY )
{
nbPoints = cHullSize = 1;
this->x = new double[1];
this->y = new double[1];
this->x[0] = x;
this->y[0] = y;
nbPoints = cHullSize = 1;
x = new double[1];
y = new double[1];
x[0] = aX;
y[0] = aY;

cHull = NULL;
parent = NULL;
Expand Down
1 change: 1 addition & 0 deletions src/core/qgsfeaturerequest.cpp
Expand Up @@ -40,6 +40,7 @@ QgsFeatureRequest::QgsFeatureRequest( QgsFeatureId fid )
QgsFeatureRequest::QgsFeatureRequest( const QgsRectangle& rect )
: mFilter( FilterRect )
, mFilterRect( rect )
, mFilterFid( -1 )
, mFilterExpression( 0 )
, mFlags( 0 )
{
Expand Down
5 changes: 3 additions & 2 deletions src/core/qgspallabeling.cpp
Expand Up @@ -78,7 +78,8 @@ using namespace pal;
// -------------

QgsPalLayerSettings::QgsPalLayerSettings()
: palLayer( NULL )
: upsidedownLabels( Upright )
, palLayer( NULL )
, mCurFeat( 0 )
, mCurFields( 0 )
, xform( NULL )
Expand All @@ -87,7 +88,7 @@ QgsPalLayerSettings::QgsPalLayerSettings()
, mFeaturesToLabel( 0 )
, mFeatsSendingToPal( 0 )
, mFeatsRegPal( 0 )
, expression( NULL )
, expression( 0 )
{
enabled = false;
isExpression = false;
Expand Down

0 comments on commit 9fb0065

Please sign in to comment.