Skip to content

Commit

Permalink
Fix for crash if removing a layer with a related composer attribute t…
Browse files Browse the repository at this point in the history
…able

git-svn-id: http://svn.osgeo.org/qgis/trunk@13537 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 20, 2010
1 parent 2015db7 commit be83e1f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/core/composer/qgscomposerattributetable.cpp
Expand Up @@ -23,7 +23,7 @@
QgsComposerAttributeTable::QgsComposerAttributeTable( QgsComposition* composition ): QgsComposerTable( composition ), mVectorLayer( 0 ), mComposerMap( 0 ), \
mMaximumNumberOfFeatures( 5 ), mShowOnlyVisibleFeatures( true )
{

connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) );
}

QgsComposerAttributeTable::~QgsComposerAttributeTable()
Expand Down Expand Up @@ -145,6 +145,17 @@ QString QgsComposerAttributeTable::attributeDisplayName( int attributeIndex, con
}
}

void QgsComposerAttributeTable::removeLayer( QString layerId )
{
if ( mVectorLayer )
{
if ( layerId == mVectorLayer->getLayerID() )
{
mVectorLayer = 0;
}
}
}

void QgsComposerAttributeTable::setSceneRect( const QRectF& rectangle )
{
double titleHeight = 2 * mGridStrokeWidth + 2 * mLineTextDistance + fontAscentMillimeters( mHeaderFont );
Expand Down
4 changes: 4 additions & 0 deletions src/core/composer/qgscomposerattributetable.h
Expand Up @@ -84,6 +84,10 @@ class CORE_EXPORT QgsComposerAttributeTable: public QgsComposerTable
/**Returns the attribute name to display in the item (attribute name or an alias if present)*/
QString attributeDisplayName( int attributeIndex, const QString& name ) const;

private slots:
/**Checks if this vector layer will be removed (and sets mVectorLayer to 0 if yes) */
void removeLayer( QString layerId );

signals:
/**This signal is emitted if the maximum number of feature changes (interactively)*/
void maximumNumerOfFeaturesChanged( int n );
Expand Down

0 comments on commit be83e1f

Please sign in to comment.