Skip to content

Commit

Permalink
atlas: don't crash the coverage layer is removed (refs #9779)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Mar 14, 2014
1 parent 3224a2f commit 1a67988
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/core/composer/qgsatlascomposition.cpp
Expand Up @@ -65,10 +65,13 @@ void QgsAtlasComposition::setCoverageLayer( QgsVectorLayer* layer )
QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )mFeatureIds.size() ) );

// Grab the first feature so that user can use it to test the style in rules.
QgsFeature fet;
layer->getFeatures().nextFeature( fet );
QgsExpression::setSpecialColumn( "$atlasfeatureid", fet.id() );
QgsExpression::setSpecialColumn( "$atlasgeometry", QVariant::fromValue( *fet.geometry() ) );
if( layer )
{
QgsFeature fet;
layer->getFeatures().nextFeature( fet );
QgsExpression::setSpecialColumn( "$atlasfeatureid", fet.id() );
QgsExpression::setSpecialColumn( "$atlasgeometry", QVariant::fromValue( *fet.geometry() ) );
}

emit coverageLayerChanged( layer );
}
Expand Down Expand Up @@ -663,6 +666,9 @@ void QgsAtlasComposition::setFilenamePattern( const QString& pattern )

void QgsAtlasComposition::updateFilenameExpression()
{
if ( !mCoverageLayer )
return;

const QgsFields& fields = mCoverageLayer->pendingFields();

if ( !mSingleFile && mFilenamePattern.size() > 0 )
Expand Down

0 comments on commit 1a67988

Please sign in to comment.