Skip to content

Commit

Permalink
Coverity fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 11, 2015
1 parent 8e4368c commit f601f92
Show file tree
Hide file tree
Showing 21 changed files with 81 additions and 42 deletions.
2 changes: 2 additions & 0 deletions src/app/gps/qwtpolar-0.1/qwt_polar_layout.cpp
Expand Up @@ -94,6 +94,8 @@ class QwtPolarLayout::PrivateData
{
public:
PrivateData():
legendPos( QwtPolarPlot::LeftLegend ),
legendRatio( 0.5 ),
margin( 0 ),
spacing( 0 )
{
Expand Down
6 changes: 6 additions & 0 deletions src/app/gps/qwtpolar-0.1/qwt_polar_plot.cpp
Expand Up @@ -41,6 +41,12 @@ class QwtPolarPlot::ScaleData
{
public:
ScaleData():
doAutoScale( false ),
minValue( 0.0 ),
maxValue( 0.0 ),
stepSize( 0.0 ),
maxMajor( 0 ),
maxMinor( 0 ),
scaleEngine( NULL )
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsapplayertreeviewmenuprovider.cpp
Expand Up @@ -91,7 +91,7 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()
menu->addAction( QgsApplication::getThemeIcon( "/mActionSetProjectCRS.png" ), tr( "Set &Project CRS from Layer" ), QgisApp::instance(), SLOT( setProjectCRSFromLayer() ) );

// style-related actions
if ( mView->selectedLayerNodes().count() == 1 )
if ( layer && mView->selectedLayerNodes().count() == 1 )
{
QMenu* menuStyleManager = new QMenu( tr( "Styles" ) );

Expand Down
3 changes: 2 additions & 1 deletion src/app/qgsmaptoolmovelabel.cpp
Expand Up @@ -176,7 +176,8 @@ void QgsMapToolMoveLabel::canvasReleaseEvent( QMouseEvent * e )
}
vlayer->endEditCommand();

mCanvas->refresh();
if ( mCanvas )
mCanvas->refresh();
}


Expand Down
11 changes: 6 additions & 5 deletions src/core/dxf/qgsdxfexport.cpp
Expand Up @@ -839,6 +839,10 @@ void QgsDxfExport::writeEntities()

QgsSymbolV2RenderContext sctx( ctx, QgsSymbolV2::MM, 1.0, false, 0, 0 );
QgsFeatureRendererV2* renderer = vl->rendererV2();
if ( !renderer )
{
continue;
}
renderer->startRender( ctx, vl->pendingFields() );

QStringList attributes = renderer->usedAttributes();
Expand Down Expand Up @@ -879,10 +883,6 @@ void QgsDxfExport::writeEntities()
}
else
{
if ( !renderer )
{
continue;
}
QgsSymbolV2List symbolList = renderer->symbolsForFeature( fet );
if ( symbolList.size() < 1 )
{
Expand Down Expand Up @@ -936,7 +936,8 @@ void QgsDxfExport::writeEntitiesSymbolLevels( QgsVectorLayer* layer )
QgsFeatureRendererV2* renderer = layer->rendererV2();
if ( !renderer )
{
//return error
//TODO return error
return;
}
QHash< QgsSymbolV2*, QList<QgsFeature> > features;

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsexpression.h
Expand Up @@ -656,7 +656,7 @@ class CORE_EXPORT QgsExpression
/**
* Used by QgsOgcUtils to create an empty
*/
QgsExpression() : mRootNode( 0 ), mRowNumber( 0 ), mCalc( 0 ) {}
QgsExpression() : mRootNode( 0 ), mRowNumber( 0 ), mScale( 0.0 ), mCalc( 0 ) {}

void initGeomCalculator();

Expand Down
6 changes: 0 additions & 6 deletions src/core/qgsvectordataprovider.h
Expand Up @@ -379,12 +379,6 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
/** Encoding */
QTextCodec* mEncoding;

/** should provider fetch also features that don't have geometry? */
bool mFetchFeaturesWithoutGeom;

/** True if geometry should be added to the features in nextFeature calls*/
bool mFetchGeom;

/** List of attribute indices to fetch with nextFeature calls*/
QgsAttributeList mAttributesToFetch;

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.cpp
Expand Up @@ -842,7 +842,7 @@ QgsRectangle QgsVectorLayer::extent()
QgsDebugMsg( "invoked with null mDataProvider" );
}

if ( mEditBuffer && mEditBuffer->mDeletedFeatureIds.isEmpty() && mEditBuffer->mChangedGeometries.isEmpty() )
if ( mDataProvider && mEditBuffer && mEditBuffer->mDeletedFeatureIds.isEmpty() && mEditBuffer->mChangedGeometries.isEmpty() )
{
mDataProvider->updateExtents();

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.h
Expand Up @@ -534,7 +534,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer

struct ValueRelationData
{
ValueRelationData() {}
ValueRelationData() : mAllowNull( false ), mOrderByValue( false ), mAllowMulti( false ) {}
ValueRelationData( QString layer, QString key, QString value, bool allowNull, bool orderByValue,
bool allowMulti = false,
QString filterExpression = QString::null )
Expand Down
40 changes: 38 additions & 2 deletions src/core/raster/qgsrasterprojector.cpp
Expand Up @@ -82,14 +82,50 @@ QgsRasterProjector::QgsRasterProjector(
, mSrcDatumTransform( -1 )
, mDestDatumTransform( -1 )
, mExtent( theExtent )
, mDestRows( 0 )
, mDestCols( 0 )
, mDestXRes( 0.0 )
, mDestYRes( 0.0 )
, mSrcRows( 0 )
, mSrcCols( 0 )
, mSrcXRes( 0.0 )
, mSrcYRes( 0.0 )
, mDestRowsPerMatrixRow( 0.0 )
, mDestColsPerMatrixCol( 0.0 )
, pHelperTop( 0 ), pHelperBottom( 0 )
, mMaxSrcXRes( theMaxSrcXRes ), mMaxSrcYRes( theMaxSrcYRes )
, mCPCols( 0 )
, mCPRows( 0 )
, mSqrTolerance( 0.0 )
, mMaxSrcXRes( theMaxSrcXRes )
, mMaxSrcYRes( theMaxSrcYRes )
, mApproximate( false )
{
QgsDebugMsg( "Entered" );
}

QgsRasterProjector::QgsRasterProjector()
: QgsRasterInterface( 0 ), mSrcDatumTransform( -1 ), mDestDatumTransform( -1 ), pHelperTop( 0 ), pHelperBottom( 0 )
: QgsRasterInterface( 0 )
, mSrcDatumTransform( -1 )
, mDestDatumTransform( -1 )
, mDestRows( 0 )
, mDestCols( 0 )
, mDestXRes( 0.0 )
, mDestYRes( 0.0 )
, mSrcRows( 0 )
, mSrcCols( 0 )
, mSrcXRes( 0.0 )
, mSrcYRes( 0.0 )
, mDestRowsPerMatrixRow( 0.0 )
, mDestColsPerMatrixCol( 0.0 )
, pHelperTop( 0 )
, pHelperBottom( 0 )
, mHelperTopRow( 0 )
, mCPCols( 0 )
, mCPRows( 0 )
, mSqrTolerance( 0.0 )
, mMaxSrcXRes( 0 )
, mMaxSrcYRes( 0 )
, mApproximate( false )
{
QgsDebugMsg( "Entered" );
}
Expand Down
4 changes: 3 additions & 1 deletion src/core/symbology-ng/qgscptcityarchive.cpp
Expand Up @@ -1692,8 +1692,10 @@ void QgsCptCityBrowserModel::fetchMore( const QModelIndex & parent )
{
QgsCptCityDataItem* item = dataItem( parent );
if ( item )
{
item->populate();
QgsDebugMsg( "path = " + item->path() );
QgsDebugMsg( "path = " + item->path() );
}
}


Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgslinesymbollayerv2.cpp
Expand Up @@ -1352,7 +1352,7 @@ void QgsMarkerLineSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element,
QgsMarkerSymbolLayerV2 *markerLayer = static_cast<QgsMarkerSymbolLayerV2 *>( layer );
if ( !markerLayer )
{
graphicStrokeElem.appendChild( doc.createComment( QString( "MarkerSymbolLayerV2 expected, %1 found. Skip it." ).arg( markerLayer->layerType() ) ) );
graphicStrokeElem.appendChild( doc.createComment( QString( "MarkerSymbolLayerV2 expected, %1 found. Skip it." ).arg( layer->layerType() ) ) );
}
else
{
Expand Down
11 changes: 7 additions & 4 deletions src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
Expand Up @@ -844,7 +844,7 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
//outlineWidth
double outlineWidth = mOutlineWidth;
QgsExpression* outlineWidthExpression = expression( "outline_width" );
if ( outlineWidthExpression )
if ( context && outlineWidthExpression )
{
outlineWidth = outlineWidthExpression->evaluate( const_cast<QgsFeature*>( context->feature() ) ).toDouble();
}
Expand Down Expand Up @@ -872,13 +872,16 @@ bool QgsSimpleMarkerSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitSc
//offset
double offsetX = 0;
double offsetY = 0;
markerOffset( *context, offsetX, offsetY );
if ( context )
{
markerOffset( *context, offsetX, offsetY );
}
QPointF off( offsetX, offsetY );

//angle
double angle = mAngle;
QgsExpression* angleExpression = expression( "angle" );
if ( angleExpression )
if ( context && angleExpression )
{
angle = angleExpression->evaluate( const_cast<QgsFeature*>( context->feature() ) ).toDouble();
}
Expand Down Expand Up @@ -1256,7 +1259,6 @@ QString QgsSvgMarkerSymbolLayerV2::layerType() const
void QgsSvgMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context )
{
QgsMarkerSymbolLayerV2::startRender( context ); // get anchor point expressions
mOrigSize = mSize; // save in case the size would be data defined
Q_UNUSED( context );
prepareExpressions( context.fields(), context.renderContext().rendererScale() );
}
Expand Down Expand Up @@ -1655,6 +1657,7 @@ QgsFontMarkerSymbolLayerV2::QgsFontMarkerSymbolLayerV2( QString fontFamily, QCha
mColor = color;
mAngle = angle;
mSize = pointSize;
mOrigSize = pointSize;
mSizeUnit = QgsSymbolV2::MM;
mOffset = QPointF( 0, 0 );
mOffsetUnit = QgsSymbolV2::MM;
Expand Down
1 change: 0 additions & 1 deletion src/core/symbology-ng/qgsmarkersymbollayerv2.h
Expand Up @@ -211,7 +211,6 @@ class CORE_EXPORT QgsSvgMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
double mOutlineWidth;
QgsSymbolV2::OutputUnit mOutlineWidthUnit;
QgsMapUnitScale mOutlineWidthMapUnitScale;
double mOrigSize;
};


Expand Down
4 changes: 0 additions & 4 deletions src/gui/qgsattributetypeloaddialog.h
Expand Up @@ -94,11 +94,7 @@ class GUI_EXPORT QgsAttributeTypeLoadDialog: public QDialog, private Ui::QgsAttr
void loadDataToValueMap();

QgsVectorLayer *mLayer;
int mIndex;


QMap<QString, QVariant> mValueMap;
QgsVectorLayer::EditType mEditType;
};

#endif
2 changes: 1 addition & 1 deletion src/gui/qgsrasterlayersaveasdialog.cpp
Expand Up @@ -88,7 +88,7 @@ QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterLayer* rasterLa
}

// Only do pyramids if dealing directly with GDAL.
if ( mDataProvider->capabilities() & QgsRasterDataProvider::BuildPyramids )
if ( mDataProvider && mDataProvider->capabilities() & QgsRasterDataProvider::BuildPyramids )
{
// setup pyramids option widget
// mPyramidsOptionsWidget->createOptionsWidget()->setType( QgsRasterFormatSaveOptionsWidget::ProfileLineEdit );
Expand Down
16 changes: 6 additions & 10 deletions src/gui/symbology-ng/qgsellipsesymbollayerv2widget.cpp
Expand Up @@ -71,7 +71,7 @@ QgsEllipseSymbolLayerV2Widget::QgsEllipseSymbolLayerV2Widget( const QgsVectorLay

void QgsEllipseSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
{
if ( layer->layerType() != "EllipseMarker" )
if ( layer && layer->layerType() != "EllipseMarker" )
{
return;
}
Expand All @@ -93,8 +93,6 @@ void QgsEllipseSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )

//set combo entries to current values
blockComboSignals( true );
if ( mLayer )
{
mSymbolWidthUnitWidget->setUnit( mLayer->symbolWidthUnit() );
mSymbolWidthUnitWidget->setMapUnitScale( mLayer->symbolWidthMapUnitScale() );
mOutlineWidthUnitWidget->setUnit( mLayer->outlineWidthUnit() );
Expand All @@ -103,13 +101,11 @@ void QgsEllipseSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
mSymbolHeightUnitWidget->setMapUnitScale( mLayer->symbolHeightMapUnitScale() );
mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
}

QPointF offsetPt = mLayer->offset();
spinOffsetX->setValue( offsetPt.x() );
spinOffsetY->setValue( offsetPt.y() );
mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
QPointF offsetPt = mLayer->offset();
spinOffsetX->setValue( offsetPt.x() );
spinOffsetY->setValue( offsetPt.y() );
mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
blockComboSignals( false );

registerDataDefinedButton( mSymbolWidthDDBtn, "width", QgsDataDefinedButton::Double, QgsDataDefinedButton::doublePosDesc() );
Expand Down
1 change: 1 addition & 0 deletions src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.cpp
Expand Up @@ -1611,6 +1611,7 @@ bool DL_Dxf::handleHatchData( DL_CreationInterface* /*creationInterface*/ )
hatchEdges != NULL &&
hatchEdgeIndex != NULL &&
hatchLoopIndex >= 0 &&
maxHatchEdges != NULL &&
hatchLoopIndex < maxHatchLoops &&
hatchEdges[hatchLoopIndex] != NULL &&
hatchEdgeIndex[hatchLoopIndex] >= 0 &&
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/spatialquery/qgsspatialquerydialog.cpp
Expand Up @@ -1059,7 +1059,7 @@ void QgsSpatialQueryDialog::signal_qgis_layerWillBeRemoved( QString idLayer )
mLayerTarget = NULL;
}
}
else
else if ( mLayerTarget )
{
populateCbOperation();
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/mssql/qgsmssqlprovider.cpp
Expand Up @@ -1729,7 +1729,7 @@ QgsVectorLayerImport::ImportError QgsMssqlProvider::createEmptyLayer(
for ( int i = 0, n = fields.size(); i < n; ++i )
{
QgsField fld = fields[i];
if ( fld.name() == primaryKey )
if ( oldToNewAttrIdxMap && fld.name() == primaryKey )
{
oldToNewAttrIdxMap->insert( fields.indexFromName( fld.name() ), 0 );
continue;
Expand Down
2 changes: 2 additions & 0 deletions src/providers/wcs/qgswcscapabilities.h
Expand Up @@ -37,6 +37,8 @@ class QNetworkReply;
/** CoverageSummary structure */
struct QgsWcsCoverageSummary
{
QgsWcsCoverageSummary() : orderId( 0 ), valid( false ), described( false ), width( 0 ), height( 0 ), hasSize( false ) { }

int orderId;
QString identifier;
QString title;
Expand Down

0 comments on commit f601f92

Please sign in to comment.