Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 26, 2018
1 parent ed63152 commit 28f6537
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions src/gui/attributetable/qgsattributetablemodel.cpp
Expand Up @@ -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();
}

Expand Down

0 comments on commit 28f6537

Please sign in to comment.