Skip to content
Permalink
Browse files

fix crash on close in attribute table (layer cache already destroyed …

…when model dtor is called)
  • Loading branch information
jef-n committed Apr 15, 2013
1 parent 42e0bad commit cb6b9515cde00ac542b8a7a725611c797b2a0b6a
@@ -232,8 +232,7 @@ void QgsVectorLayerCache::geometryChanged( QgsFeatureId fid, QgsGeometry& geom )

void QgsVectorLayerCache::layerDeleted()
{
emit( cachedLayerDeleted() );

emit cachedLayerDeleted();
mLayer = NULL;
}

@@ -65,7 +65,7 @@ class CORE_EXPORT QgsVectorLayerCache : public QObject
// That's the reason we need this wrapper:
// Inform the cache that this feature has been removed
mCache->featureRemoved( mFeature->id() );
delete( mFeature );
delete mFeature;
}

inline const QgsFeature* feature() { return mFeature; }
@@ -86,7 +86,6 @@ class CORE_EXPORT QgsVectorLayerCache : public QObject
*
* @param cacheSize indicates the maximum number of features to keep in the cache
*/

void setCacheSize( int cacheSize );

/**
@@ -57,17 +57,13 @@ QgsAttributeTableModel::QgsAttributeTableModel( QgsVectorLayerCache *layerCache,

QgsAttributeTableModel::~QgsAttributeTableModel()
{
if ( layer() )
const QMap<QString, QVariant> *item;
foreach ( item, mValueMaps )
{
const QgsFields& fields = layer()->pendingFields();
for ( int idx = 0; idx < fields.count(); ++idx )
{
if ( layer()->editType( idx ) != QgsVectorLayer::ValueRelation )
continue;

delete mValueMaps.take( idx );
}
delete item;
}

mValueMaps.clear();
}

bool QgsAttributeTableModel::loadFeatureAtId( QgsFeatureId fid ) const
@@ -165,14 +161,13 @@ void QgsAttributeTableModel::layerDeleted()
removeRows( 0, rowCount() );
endRemoveRows();

const QgsFields& fields = layer()->pendingFields();
for ( int idx = 0; idx < fields.count(); ++idx )
const QMap<QString, QVariant> *item;
foreach ( item, mValueMaps )
{
if ( layer()->editType( idx ) != QgsVectorLayer::ValueRelation )
continue;

delete mValueMaps.take( idx );
delete item;
}

mValueMaps.clear();
}

void QgsAttributeTableModel::attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value )

0 comments on commit cb6b951

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