Skip to content

Commit

Permalink
Fix crashes and inconsistent ui when atlas is set to a geometryless l…
Browse files Browse the repository at this point in the history
…ayer
  • Loading branch information
nyalldawson committed Oct 7, 2015
1 parent dcbe0d3 commit be42fc2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
20 changes: 16 additions & 4 deletions src/app/composer/qgscomposermapwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap )
connect( atlas, SIGNAL( coverageLayerChanged( QgsVectorLayer* ) ),
this, SLOT( populateDataDefinedButtons() ) );
connect( atlas, SIGNAL( toggled( bool ) ), this, SLOT( populateDataDefinedButtons() ) );

compositionAtlasToggled( atlas->enabled() );
}
}

Expand Down Expand Up @@ -281,7 +283,9 @@ QgsComposerObject::DataDefinedProperty QgsComposerMapWidget::ddPropertyForWidget

void QgsComposerMapWidget::compositionAtlasToggled( bool atlasEnabled )
{
if ( atlasEnabled )
if ( atlasEnabled &&
mComposerMap && mComposerMap->composition() && mComposerMap->composition()->atlasComposition().coverageLayer()
&& mComposerMap->composition()->atlasComposition().coverageLayer()->wkbType() != QGis::WKBNoGeometry )
{
mAtlasCheckBox->setEnabled( true );
}
Expand Down Expand Up @@ -1140,13 +1144,21 @@ void QgsComposerMapWidget::refreshMapComboBox()

void QgsComposerMapWidget::atlasLayerChanged( QgsVectorLayer* layer )
{
// enable or disable fixed scale control based on layer type
if ( !layer || !mAtlasCheckBox->isChecked() )
if ( !layer || layer->wkbType() == QGis::WKBNoGeometry )
{
//geometryless layer, disable atlas control
mAtlasCheckBox->setChecked( false );
mAtlasCheckBox->setEnabled( false );
return;
}
else
{
mAtlasCheckBox->setEnabled( true );
}

toggleAtlasScalingOptionsByLayerType();
// enable or disable fixed scale control based on layer type
if ( mAtlasCheckBox->isChecked() )
toggleAtlasScalingOptionsByLayerType();
}

bool QgsComposerMapWidget::hasPredefinedScales() const
Expand Down
4 changes: 3 additions & 1 deletion src/core/composer/qgsatlascomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ bool QgsAtlasComposition::prepareForFeature( const int featureI, const bool upda
void QgsAtlasComposition::computeExtent( QgsComposerMap* map )
{
// compute the extent of the current feature, in the crs of the specified map
if ( !mCurrentFeature.constGeometry() )
return;

const QgsCoordinateReferenceSystem& coverage_crs = mCoverageLayer->crs();
// transformation needed for feature geometries
Expand All @@ -516,7 +518,7 @@ void QgsAtlasComposition::computeExtent( QgsComposerMap* map )

void QgsAtlasComposition::prepareMap( QgsComposerMap* map )
{
if ( !map->atlasDriven() )
if ( !map->atlasDriven() || mCoverageLayer->wkbType() == QGis::WKBNoGeometry )
{
return;
}
Expand Down

0 comments on commit be42fc2

Please sign in to comment.