[QGIS Commit] r13537 - trunk/qgis/src/core/composer
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Thu May 20 10:18:27 EDT 2010
Author: mhugent
Date: 2010-05-20 10:18:26 -0400 (Thu, 20 May 2010)
New Revision: 13537
Modified:
trunk/qgis/src/core/composer/qgscomposerattributetable.cpp
trunk/qgis/src/core/composer/qgscomposerattributetable.h
Log:
Fix for crash if removing a layer with a related composer attribute table
Modified: trunk/qgis/src/core/composer/qgscomposerattributetable.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerattributetable.cpp 2010-05-20 13:39:20 UTC (rev 13536)
+++ trunk/qgis/src/core/composer/qgscomposerattributetable.cpp 2010-05-20 14:18:26 UTC (rev 13537)
@@ -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()
@@ -145,6 +145,17 @@
}
}
+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 );
Modified: trunk/qgis/src/core/composer/qgscomposerattributetable.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposerattributetable.h 2010-05-20 13:39:20 UTC (rev 13536)
+++ trunk/qgis/src/core/composer/qgscomposerattributetable.h 2010-05-20 14:18:26 UTC (rev 13537)
@@ -84,6 +84,10 @@
/**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 );
More information about the QGIS-commit
mailing list