Skip to content
Permalink
Browse files

Fix crashes and inconsistent ui when atlas is set to a geometryless l…

…ayer
  • Loading branch information
nyalldawson committed Oct 7, 2015
1 parent dcbe0d3 commit be42fc2667ed46d00b7529e46e8d628f993dc6d3
Showing with 19 additions and 5 deletions.
  1. +16 −4 src/app/composer/qgscomposermapwidget.cpp
  2. +3 −1 src/core/composer/qgsatlascomposition.cpp
@@ -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() );
}
}

@@ -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 );
}
@@ -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
@@ -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
@@ -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;
}

0 comments on commit be42fc2

Please sign in to comment.
You can’t perform that action at this time.