mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Fix some coverity null pointer dereference issues
This commit is contained in:
parent
66e10e4937
commit
bfdd9dc0b0
@ -113,10 +113,13 @@ void QgsComposerTableBackgroundColorsDialog::setGuiElementValues()
|
||||
Q_FOREACH ( QgsComposerTableV2::CellStyleGroup styleGroup, mCheckBoxMap.keys() )
|
||||
{
|
||||
mCheckBoxMap.value( styleGroup )->setChecked( mComposerTable->cellStyle( styleGroup )->enabled );
|
||||
mColorButtonMap.value( styleGroup )->setEnabled( mComposerTable->cellStyle( styleGroup )->enabled );
|
||||
mColorButtonMap.value( styleGroup )->setColor( mComposerTable->cellStyle( styleGroup )->cellBackgroundColor );
|
||||
mColorButtonMap.value( styleGroup )->setAllowAlpha( true );
|
||||
mColorButtonMap.value( styleGroup )->setColorDialogTitle( tr( "Select background color" ) );
|
||||
QgsColorButton* button = mColorButtonMap.value( styleGroup );
|
||||
if ( !button )
|
||||
continue;
|
||||
button->setEnabled( mComposerTable->cellStyle( styleGroup )->enabled );
|
||||
button->setColor( mComposerTable->cellStyle( styleGroup )->cellBackgroundColor );
|
||||
button->setAllowAlpha( true );
|
||||
button->setColorDialogTitle( tr( "Select background color" ) );
|
||||
}
|
||||
|
||||
mDefaultColorButton->setColor( mComposerTable->backgroundColor() );
|
||||
|
@ -231,7 +231,9 @@ bool QgsComposerTableV2::readXml( const QDomElement &itemElem, const QDomDocumen
|
||||
if ( !styleList.isEmpty() )
|
||||
{
|
||||
QDomElement styleElem = styleList.at( 0 ).toElement();
|
||||
mCellStyles.value( it.key() )->readXml( styleElem );
|
||||
QgsComposerTableStyle* style = mCellStyles.value( it.key() );
|
||||
if ( style )
|
||||
style->readXml( styleElem );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1225,24 +1227,33 @@ QString QgsComposerTableV2::wrappedText( const QString &value, double columnWidt
|
||||
QColor QgsComposerTableV2::backgroundColor( int row, int column ) const
|
||||
{
|
||||
QColor color = mBackgroundColor;
|
||||
if ( mCellStyles.value( OddColumns )->enabled && column % 2 == 0 )
|
||||
color = mCellStyles.value( OddColumns )->cellBackgroundColor;
|
||||
if ( mCellStyles.value( EvenColumns )->enabled && column % 2 == 1 )
|
||||
color = mCellStyles.value( EvenColumns )->cellBackgroundColor;
|
||||
if ( mCellStyles.value( OddRows )->enabled && row % 2 == 0 )
|
||||
color = mCellStyles.value( OddRows )->cellBackgroundColor;
|
||||
if ( mCellStyles.value( EvenRows )->enabled && row % 2 == 1 )
|
||||
color = mCellStyles.value( EvenRows )->cellBackgroundColor;
|
||||
if ( mCellStyles.value( FirstColumn )->enabled && column == 0 )
|
||||
color = mCellStyles.value( FirstColumn )->cellBackgroundColor;
|
||||
if ( mCellStyles.value( LastColumn )->enabled && column == mColumns.count() - 1 )
|
||||
color = mCellStyles.value( LastColumn )->cellBackgroundColor;
|
||||
if ( mCellStyles.value( HeaderRow )->enabled && row == -1 )
|
||||
color = mCellStyles.value( HeaderRow )->cellBackgroundColor;
|
||||
if ( mCellStyles.value( FirstRow )->enabled && row == 0 )
|
||||
color = mCellStyles.value( FirstRow )->cellBackgroundColor;
|
||||
if ( mCellStyles.value( LastRow )->enabled && row == mTableContents.count() - 1 )
|
||||
color = mCellStyles.value( LastRow )->cellBackgroundColor;
|
||||
if ( QgsComposerTableStyle* style = mCellStyles.value( OddColumns ) )
|
||||
if ( style->enabled && column % 2 == 0 )
|
||||
color = style->cellBackgroundColor;
|
||||
if ( QgsComposerTableStyle* style = mCellStyles.value( EvenColumns ) )
|
||||
if ( style->enabled && column % 2 == 1 )
|
||||
color = style->cellBackgroundColor;
|
||||
if ( QgsComposerTableStyle* style = mCellStyles.value( OddRows ) )
|
||||
if ( style->enabled && row % 2 == 0 )
|
||||
color = style->cellBackgroundColor;
|
||||
if ( QgsComposerTableStyle* style = mCellStyles.value( EvenRows ) )
|
||||
if ( style->enabled && row % 2 == 1 )
|
||||
color = style->cellBackgroundColor;
|
||||
if ( QgsComposerTableStyle* style = mCellStyles.value( FirstColumn ) )
|
||||
if ( style->enabled && column == 0 )
|
||||
color = style->cellBackgroundColor;
|
||||
if ( QgsComposerTableStyle* style = mCellStyles.value( LastColumn ) )
|
||||
if ( style->enabled && column == mColumns.count() - 1 )
|
||||
color = style->cellBackgroundColor;
|
||||
if ( QgsComposerTableStyle* style = mCellStyles.value( HeaderRow ) )
|
||||
if ( style->enabled && row == -1 )
|
||||
color = style->cellBackgroundColor;
|
||||
if ( QgsComposerTableStyle* style = mCellStyles.value( FirstRow ) )
|
||||
if ( style->enabled && row == 0 )
|
||||
color = style->cellBackgroundColor;
|
||||
if ( QgsComposerTableStyle* style = mCellStyles.value( LastRow ) )
|
||||
if ( style->enabled && row == mTableContents.count() - 1 )
|
||||
color = style->cellBackgroundColor;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
@ -520,10 +520,13 @@ QgsAttributeEditorElement* QgsEditFormConfig::attributeEditorElementFromDomEleme
|
||||
newElement = relElement;
|
||||
}
|
||||
|
||||
if ( elem.hasAttribute( QStringLiteral( "showLabel" ) ) )
|
||||
newElement->setShowLabel( elem.attribute( QStringLiteral( "showLabel" ) ).toInt() );
|
||||
else
|
||||
newElement->setShowLabel( true );
|
||||
if ( newElement )
|
||||
{
|
||||
if ( elem.hasAttribute( QStringLiteral( "showLabel" ) ) )
|
||||
newElement->setShowLabel( elem.attribute( QStringLiteral( "showLabel" ) ).toInt() );
|
||||
else
|
||||
newElement->setShowLabel( true );
|
||||
}
|
||||
|
||||
return newElement;
|
||||
}
|
||||
|
@ -746,10 +746,17 @@ void QgsVectorLayerFeatureIterator::addVirtualAttributes( QgsFeature& f )
|
||||
void QgsVectorLayerFeatureIterator::addExpressionAttribute( QgsFeature& f, int attrIndex )
|
||||
{
|
||||
QgsExpression* exp = mExpressionFieldInfo.value( attrIndex );
|
||||
mExpressionContext->setFeature( f );
|
||||
QVariant val = exp->evaluate( mExpressionContext.data() );
|
||||
mSource->mFields.at( attrIndex ).convertCompatible( val );
|
||||
f.setAttribute( attrIndex, val );
|
||||
if ( exp )
|
||||
{
|
||||
mExpressionContext->setFeature( f );
|
||||
QVariant val = exp->evaluate( mExpressionContext.data() );
|
||||
mSource->mFields.at( attrIndex ).convertCompatible( val );
|
||||
f.setAttribute( attrIndex, val );
|
||||
}
|
||||
else
|
||||
{
|
||||
f.setAttribute( attrIndex, QVariant() );
|
||||
}
|
||||
}
|
||||
|
||||
bool QgsVectorLayerFeatureIterator::prepareSimplification( const QgsSimplifyMethod& simplifyMethod )
|
||||
|
@ -948,6 +948,10 @@ void QgsRasterLayer::setContrastEnhancement( QgsContrastEnhancement::ContrastEnh
|
||||
myRasterRenderer = myPseudoColorRenderer;
|
||||
myMinMaxOrigin = myPseudoColorRenderer->minMaxOrigin();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Q_FOREACH ( int myBand, myBands )
|
||||
{
|
||||
|
@ -125,7 +125,8 @@ QStringList QgsRendererRegistry::renderersList( QgsRendererAbstractMetadata::Lay
|
||||
QStringList renderers;
|
||||
Q_FOREACH ( const QString& renderer, mRenderersOrder )
|
||||
{
|
||||
if ( mRenderers.value( renderer )->compatibleLayerTypes() & layerTypes )
|
||||
QgsRendererAbstractMetadata* r = mRenderers.value( renderer );
|
||||
if ( r && r->compatibleLayerTypes() & layerTypes )
|
||||
renderers << renderer;
|
||||
}
|
||||
return renderers;
|
||||
|
@ -344,12 +344,8 @@ void QgsVariableEditorTree::refreshScopeVariables( QgsExpressionContextScope* sc
|
||||
|
||||
Q_FOREACH ( const QString& name, scope->filteredVariableNames() )
|
||||
{
|
||||
QTreeWidgetItem* item;
|
||||
if ( mVariableToItem.contains( qMakePair( scopeIndex, name ) ) )
|
||||
{
|
||||
item = mVariableToItem.value( qMakePair( scopeIndex, name ) );
|
||||
}
|
||||
else
|
||||
QTreeWidgetItem* item = mVariableToItem.value( qMakePair( scopeIndex, name ) );
|
||||
if ( !item )
|
||||
{
|
||||
item = new QTreeWidgetItem( scopeItem );
|
||||
mVariableToItem.insert( qMakePair( scopeIndex, name ), item );
|
||||
|
@ -858,6 +858,10 @@ bool QgsGrassMapsetItem::handleDrop( const QMimeData * data, Qt::DropAction )
|
||||
QgsGrassObject vectorObject( mGrassObject.gisdbase(), mGrassObject.location(), mGrassObject.mapset(), destName, QgsGrassObject::Vector );
|
||||
import = new QgsGrassVectorImport( vectorProvider, vectorObject ); // takes provider ownership
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
connect( import, SIGNAL( finished( QgsGrassImport* ) ), SLOT( onImportFinished( QgsGrassImport* ) ) );
|
||||
|
||||
|
@ -2925,11 +2925,12 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint & thePoint, Qgs
|
||||
params.insert( QStringLiteral( "featureType" ), featureTypeName );
|
||||
params.insert( QStringLiteral( "getFeatureInfoUrl" ), requestUrl.toString() );
|
||||
featureStore.setParams( params );
|
||||
Q_FOREACH ( QgsFeatureId id, features.keys() )
|
||||
QMap<QgsFeatureId, QgsFeature* >::const_iterator featIt = features.constBegin();
|
||||
for ( ; featIt != features.constEnd(); ++featIt )
|
||||
{
|
||||
QgsFeature * feature = features.value( id );
|
||||
QgsFeature * feature = featIt.value();
|
||||
|
||||
QgsDebugMsg( QString( "feature id = %1 : %2 attributes" ).arg( id ).arg( feature->attributes().size() ) );
|
||||
QgsDebugMsg( QString( "feature id = %1 : %2 attributes" ).arg( featIt.key() ).arg( feature->attributes().size() ) );
|
||||
|
||||
if ( coordinateTransform.isValid() && feature->hasGeometry() )
|
||||
{
|
||||
|
@ -1216,6 +1216,7 @@ void TestQgsGrassProvider::edit()
|
||||
grassLayer->startEditing();
|
||||
grassProvider->startEditing( grassLayer );
|
||||
|
||||
Q_ASSERT( expectedLayer );
|
||||
expectedLayer->startEditing();
|
||||
}
|
||||
|
||||
@ -1582,7 +1583,9 @@ bool TestQgsGrassProvider::compare( QMap<QString, QgsVectorLayer *> layers, bool
|
||||
{
|
||||
Q_FOREACH ( const QString & grassUri, layers.keys() )
|
||||
{
|
||||
if ( !compare( grassUri, layers.value( grassUri ), ok ) )
|
||||
QgsVectorLayer* layer = layers.value( grassUri );
|
||||
Q_ASSERT( layer );
|
||||
if ( !compare( grassUri, layer, ok ) )
|
||||
{
|
||||
reportRow( "comparison failed: " + grassUri );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user