Skip to content
Permalink
Browse files

Fix atlas segfaults

  • Loading branch information
Hugo Mercier
Hugo Mercier committed Oct 5, 2012
1 parent d904da4 commit e3536e4d838770c5ff05b8d5bc78734ee9e9f7c3
Showing with 42 additions and 9 deletions.
  1. +36 −6 src/app/composer/qgsatlascompositionwidget.cpp
  2. +6 −3 src/core/composer/qgsatlascomposition.cpp
@@ -98,6 +98,10 @@ void QgsAtlasCompositionWidget::onLayerRemoved( QString layerName )
break;
}
}
if ( mAtlasCoverageLayerComboBox->count() == 0 )
{
mAtlas->setCoverageLayer( 0 );
}
}

void QgsAtlasCompositionWidget::onLayerAdded( QgsMapLayer* map )
@@ -108,24 +112,36 @@ void QgsAtlasCompositionWidget::onLayerAdded( QgsMapLayer* map )
{
mAtlasCoverageLayerComboBox->addItem( map->id(), qVariantFromValue( (void*)map ) );
}
if ( mAtlasCoverageLayerComboBox->count() == 1 )
{
mAtlas->setCoverageLayer( vectorLayer );
}
}

void QgsAtlasCompositionWidget::onComposerMapAdded( QgsComposerMap* map )
{
mComposerMapComboBox->addItem( tr( "Map %1" ).arg( map->id() ), map->id() );
mComposerMapComboBox->addItem( tr( "Map %1" ).arg( map->id() ), qVariantFromValue( (void*)map ) );
if ( mComposerMapComboBox->count() == 1 )
{
mAtlas->setComposerMap( map );
}
}

void QgsAtlasCompositionWidget::onItemRemoved( QgsComposerItem* item )
{
QgsComposerMap* map = dynamic_cast<QgsComposerMap*>( item );
if ( map )
{
int idx = mComposerMapComboBox->findData( map->id() );
int idx = mComposerMapComboBox->findData( qVariantFromValue( (void*)map ) );
if ( idx != -1 )
{
mComposerMapComboBox->removeItem( idx );
}
}
if ( mComposerMapComboBox->count() == 0 )
{
mAtlas->setComposerMap( 0 );
}
}

void QgsAtlasCompositionWidget::on_mAtlasCoverageLayerComboBox_currentIndexChanged( int index )
@@ -135,8 +151,15 @@ void QgsAtlasCompositionWidget::on_mAtlasCoverageLayerComboBox_currentIndexChang
{
return;
}
QgsVectorLayer* layer = reinterpret_cast<QgsVectorLayer*>(mAtlasCoverageLayerComboBox->itemData( index ).value<void*>());
atlasMap->setCoverageLayer( layer );
if ( index == -1 )
{
atlasMap->setCoverageLayer( 0 );
}
else
{
QgsVectorLayer* layer = reinterpret_cast<QgsVectorLayer*>(mAtlasCoverageLayerComboBox->itemData( index ).value<void*>());
atlasMap->setCoverageLayer( layer );
}
}

void QgsAtlasCompositionWidget::on_mComposerMapComboBox_currentIndexChanged( int index )
@@ -146,8 +169,15 @@ void QgsAtlasCompositionWidget::on_mComposerMapComboBox_currentIndexChanged( int
{
return;
}
QgsComposerMap* map = reinterpret_cast<QgsComposerMap*>(mComposerMapComboBox->itemData( index ).value<void*>());
atlasMap->setComposerMap( map );
if ( index == -1 )
{
atlasMap->setComposerMap( 0 );
}
else
{
QgsComposerMap* map = reinterpret_cast<QgsComposerMap*>(mComposerMapComboBox->itemData( index ).value<void*>());
atlasMap->setComposerMap( map );
}
}

void QgsAtlasCompositionWidget::on_mAtlasFilenamePatternEdit_textChanged( const QString& text )
@@ -48,9 +48,12 @@ void QgsAtlasComposition::setCoverageLayer( QgsVectorLayer* layer )
{
mCoverageLayer = layer;

// update the number of features
QgsVectorDataProvider* provider = mCoverageLayer->dataProvider();
QgsExpression::setSpecialColumn( "$numfeatures", QVariant( (int)provider->featureCount() ) );
if ( mCoverageLayer != 0 )
{
// update the number of features
QgsVectorDataProvider* provider = mCoverageLayer->dataProvider();
QgsExpression::setSpecialColumn( "$numfeatures", QVariant( (int)provider->featureCount() ) );
}
}

void QgsAtlasComposition::beginRender()

0 comments on commit e3536e4

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