Skip to content

Commit 4b7876c

Browse files
committed
Fix some Coverity null derefence warnings
1 parent 17db101 commit 4b7876c

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

src/app/composer/qgscomposertablebackgroundcolorsdialog.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,15 @@ void QgsComposerTableBackgroundColorsDialog::apply()
7373
composition->beginMultiFrameCommand( mComposerTable, tr( "Table background customisation" ), QgsComposerMultiFrameMergeCommand::TableCellStyle );
7474
}
7575

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

82-
mComposerTable->setCellStyle( styleGroup, style );
84+
mComposerTable->setCellStyle( checkBoxIt.key(), style );
8385
}
8486

8587
mComposerTable->setBackgroundColor( mDefaultColorButton->color() );

src/app/nodetool/qgsmaptoolnodetool.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,14 @@ void QgsMapToolNodeTool::canvasMoveEvent( QgsMapMouseEvent* e )
166166
double deltaX = curPos.x() - pressPos.x();
167167
double deltaY = curPos.y() - pressPos.y();
168168

169-
Q_FOREACH ( QgsFeatureId fid, mMoveRubberBands.keys() )
169+
QMap<QgsFeatureId, QgsGeometryRubberBand*>::const_iterator moveBandsIt = mMoveRubberBands.constBegin();
170+
for ( ; moveBandsIt != mMoveRubberBands.constEnd(); ++moveBandsIt )
170171
{
171172
typedef QPair<QgsVertexId, QgsPointV2> MoveVertex;
172-
Q_FOREACH ( const MoveVertex& pair, mMoveVertices[fid] )
173+
Q_FOREACH ( const MoveVertex& pair, mMoveVertices[ moveBandsIt.key()] )
173174
{
174175
QgsPointV2 newPos( pair.second.x() + deltaX, pair.second.y() + deltaY );
175-
mMoveRubberBands.value( fid )->moveVertex( pair.first, newPos );
176+
moveBandsIt.value()->moveVertex( pair.first, newPos );
176177
}
177178
}
178179
}

src/app/qgsvectorlayerproperties.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,10 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
295295

296296
mLayersDependenciesTreeGroup.reset( QgsProject::instance()->layerTreeRoot()->clone() );
297297
QgsLayerTreeLayer* layer = mLayersDependenciesTreeGroup->findLayer( mLayer->id() );
298-
layer->parent()->takeChild( layer );
298+
if ( layer )
299+
{
300+
layer->parent()->takeChild( layer );
301+
}
299302
mLayersDependenciesTreeModel.reset( new QgsLayerTreeModel( mLayersDependenciesTreeGroup.data() ) );
300303
// use visibility as selection
301304
mLayersDependenciesTreeModel->setFlag( QgsLayerTreeModel::AllowNodeChangeVisibility );

src/core/composer/qgscomposertablev2.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,12 @@ bool QgsComposerTableV2::writeXml( QDomElement& elem, QDomDocument & doc, bool i
142142
{
143143
QString styleName = it.value();
144144
QDomElement styleElem = doc.createElement( styleName );
145-
mCellStyles.value( it.key() )->writeXml( styleElem, doc );
146-
stylesElem.appendChild( styleElem );
145+
QgsComposerTableStyle* style = mCellStyles.value( it.key() );
146+
if ( style )
147+
{
148+
style->writeXml( styleElem, doc );
149+
stylesElem.appendChild( styleElem );
150+
}
147151
}
148152
elem.appendChild( stylesElem );
149153

src/core/symbology-ng/qgscptcityarchive.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ QString QgsCptCityArchive::baseDir( QString archiveName )
115115
// search for matching archive in the registry
116116
if ( archiveName.isNull() )
117117
archiveName = DEFAULT_CPTCITY_ARCHIVE;
118-
if ( mArchiveRegistry.contains( archiveName ) )
119-
return mArchiveRegistry.value( archiveName )->baseDir();
118+
if ( QgsCptCityArchive* archive = mArchiveRegistry.value( archiveName, nullptr ) )
119+
return archive->baseDir();
120120
else
121121
return defaultBaseDir();
122122
}

0 commit comments

Comments
 (0)