Skip to content

Commit

Permalink
Fix some Coverity null derefence warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 3, 2016
1 parent 17db101 commit 4b7876c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
10 changes: 6 additions & 4 deletions src/app/composer/qgscomposertablebackgroundcolorsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ void QgsComposerTableBackgroundColorsDialog::apply()
composition->beginMultiFrameCommand( mComposerTable, tr( "Table background customisation" ), QgsComposerMultiFrameMergeCommand::TableCellStyle );
}

Q_FOREACH ( QgsComposerTableV2::CellStyleGroup styleGroup, mCheckBoxMap.keys() )
QMap< QgsComposerTableV2::CellStyleGroup, QCheckBox* >::const_iterator checkBoxIt = mCheckBoxMap.constBegin();
for ( ; checkBoxIt != mCheckBoxMap.constEnd(); ++checkBoxIt )
{
QgsComposerTableStyle style;
style.enabled = mCheckBoxMap.value( styleGroup )->isChecked();
style.cellBackgroundColor = mColorButtonMap.value( styleGroup )->color();
style.enabled = checkBoxIt.value()->isChecked();
if ( QgsColorButton* button = mColorButtonMap.value( checkBoxIt.key() ) )
style.cellBackgroundColor = button->color();

mComposerTable->setCellStyle( styleGroup, style );
mComposerTable->setCellStyle( checkBoxIt.key(), style );
}

mComposerTable->setBackgroundColor( mDefaultColorButton->color() );
Expand Down
7 changes: 4 additions & 3 deletions src/app/nodetool/qgsmaptoolnodetool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,14 @@ void QgsMapToolNodeTool::canvasMoveEvent( QgsMapMouseEvent* e )
double deltaX = curPos.x() - pressPos.x();
double deltaY = curPos.y() - pressPos.y();

Q_FOREACH ( QgsFeatureId fid, mMoveRubberBands.keys() )
QMap<QgsFeatureId, QgsGeometryRubberBand*>::const_iterator moveBandsIt = mMoveRubberBands.constBegin();
for ( ; moveBandsIt != mMoveRubberBands.constEnd(); ++moveBandsIt )
{
typedef QPair<QgsVertexId, QgsPointV2> MoveVertex;
Q_FOREACH ( const MoveVertex& pair, mMoveVertices[fid] )
Q_FOREACH ( const MoveVertex& pair, mMoveVertices[ moveBandsIt.key()] )
{
QgsPointV2 newPos( pair.second.x() + deltaX, pair.second.y() + deltaY );
mMoveRubberBands.value( fid )->moveVertex( pair.first, newPos );
moveBandsIt.value()->moveVertex( pair.first, newPos );
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/app/qgsvectorlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,10 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(

mLayersDependenciesTreeGroup.reset( QgsProject::instance()->layerTreeRoot()->clone() );
QgsLayerTreeLayer* layer = mLayersDependenciesTreeGroup->findLayer( mLayer->id() );
layer->parent()->takeChild( layer );
if ( layer )
{
layer->parent()->takeChild( layer );
}
mLayersDependenciesTreeModel.reset( new QgsLayerTreeModel( mLayersDependenciesTreeGroup.data() ) );
// use visibility as selection
mLayersDependenciesTreeModel->setFlag( QgsLayerTreeModel::AllowNodeChangeVisibility );
Expand Down
8 changes: 6 additions & 2 deletions src/core/composer/qgscomposertablev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,12 @@ bool QgsComposerTableV2::writeXml( QDomElement& elem, QDomDocument & doc, bool i
{
QString styleName = it.value();
QDomElement styleElem = doc.createElement( styleName );
mCellStyles.value( it.key() )->writeXml( styleElem, doc );
stylesElem.appendChild( styleElem );
QgsComposerTableStyle* style = mCellStyles.value( it.key() );
if ( style )
{
style->writeXml( styleElem, doc );
stylesElem.appendChild( styleElem );
}
}
elem.appendChild( stylesElem );

Expand Down
4 changes: 2 additions & 2 deletions src/core/symbology-ng/qgscptcityarchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ QString QgsCptCityArchive::baseDir( QString archiveName )
// search for matching archive in the registry
if ( archiveName.isNull() )
archiveName = DEFAULT_CPTCITY_ARCHIVE;
if ( mArchiveRegistry.contains( archiveName ) )
return mArchiveRegistry.value( archiveName )->baseDir();
if ( QgsCptCityArchive* archive = mArchiveRegistry.value( archiveName, nullptr ) )
return archive->baseDir();
else
return defaultBaseDir();
}
Expand Down

0 comments on commit 4b7876c

Please sign in to comment.