Skip to content

Commit be83e1f

Browse files
author
mhugent
committed
Fix for crash if removing a layer with a related composer attribute table
git-svn-id: http://svn.osgeo.org/qgis/trunk@13537 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2015db7 commit be83e1f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/core/composer/qgscomposerattributetable.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
QgsComposerAttributeTable::QgsComposerAttributeTable( QgsComposition* composition ): QgsComposerTable( composition ), mVectorLayer( 0 ), mComposerMap( 0 ), \
2424
mMaximumNumberOfFeatures( 5 ), mShowOnlyVisibleFeatures( true )
2525
{
26-
26+
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) );
2727
}
2828

2929
QgsComposerAttributeTable::~QgsComposerAttributeTable()
@@ -145,6 +145,17 @@ QString QgsComposerAttributeTable::attributeDisplayName( int attributeIndex, con
145145
}
146146
}
147147

148+
void QgsComposerAttributeTable::removeLayer( QString layerId )
149+
{
150+
if ( mVectorLayer )
151+
{
152+
if ( layerId == mVectorLayer->getLayerID() )
153+
{
154+
mVectorLayer = 0;
155+
}
156+
}
157+
}
158+
148159
void QgsComposerAttributeTable::setSceneRect( const QRectF& rectangle )
149160
{
150161
double titleHeight = 2 * mGridStrokeWidth + 2 * mLineTextDistance + fontAscentMillimeters( mHeaderFont );

src/core/composer/qgscomposerattributetable.h

+4
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ class CORE_EXPORT QgsComposerAttributeTable: public QgsComposerTable
8484
/**Returns the attribute name to display in the item (attribute name or an alias if present)*/
8585
QString attributeDisplayName( int attributeIndex, const QString& name ) const;
8686

87+
private slots:
88+
/**Checks if this vector layer will be removed (and sets mVectorLayer to 0 if yes) */
89+
void removeLayer( QString layerId );
90+
8791
signals:
8892
/**This signal is emitted if the maximum number of feature changes (interactively)*/
8993
void maximumNumerOfFeaturesChanged( int n );

0 commit comments

Comments
 (0)