Skip to content
Permalink
Browse files

Do not crash when removing a layer with attr table open

.. in show features in current extent mode.

Cherry picked from master d62087e
  • Loading branch information
elpaso authored and nyalldawson committed Jul 24, 2018
1 parent ed63152 commit 28f6537c837d470b58e844e1bc3b7fe8ead8e116
Showing with 22 additions and 18 deletions.
  1. +22 −18 src/gui/attributetable/qgsattributetablemodel.cpp
@@ -429,32 +429,36 @@ void QgsAttributeTableModel::loadLayer()
removeRows( 0, rowCount() );
}

QgsFeatureIterator features = mLayerCache->getFeatures( mFeatureRequest );

int i = 0;
// Layer might have been deleted and cache set to nullptr!
if ( mLayerCache )
{
QgsFeatureIterator features = mLayerCache->getFeatures( mFeatureRequest );

QTime t;
t.start();
int i = 0;

while ( features.nextFeature( mFeat ) )
{
++i;
QTime t;
t.start();

if ( t.elapsed() > 1000 )
while ( features.nextFeature( mFeat ) )
{
bool cancel = false;
emit progress( i, cancel );
if ( cancel )
break;
++i;

t.restart();
if ( t.elapsed() > 1000 )
{
bool cancel = false;
emit progress( i, cancel );
if ( cancel )
break;

t.restart();
}
featureAdded( mFeat.id(), true );
}
featureAdded( mFeat.id(), true );
}

emit finished();
emit finished();
connect( mLayerCache, &QgsVectorLayerCache::invalidated, this, &QgsAttributeTableModel::loadLayer, Qt::UniqueConnection );
}

connect( mLayerCache, &QgsVectorLayerCache::invalidated, this, &QgsAttributeTableModel::loadLayer, Qt::UniqueConnection );
endResetModel();
}

0 comments on commit 28f6537

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