Skip to content
Permalink
Browse files
Merge pull request #4535 from boundlessgeo/attributetable-fixes-16492
Attributetable fixes  crash #16492
  • Loading branch information
elpaso committed May 12, 2017
2 parents a0c6872 + 5134791 commit 3f9c4e5fa7057583303d016c5e5377ecb89baab3
@@ -1844,7 +1844,7 @@ Is emitted, before changes are rolled back
%Docstring
Emitted when a feature has been deleted.

If you do expensive operations in a slot connected to this, you should prever to use
If you do expensive operations in a slot connected to this, you should prefer to use
featuresDeleted( const QgsFeatureIds& ).

\param fid The id of the feature which has been deleted
@@ -1710,7 +1710,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
/**
* Emitted when a feature has been deleted.
*
* If you do expensive operations in a slot connected to this, you should prever to use
* If you do expensive operations in a slot connected to this, you should prefer to use
* featuresDeleted( const QgsFeatureIds& ).
*
* \param fid The id of the feature which has been deleted
@@ -97,9 +97,18 @@ void QgsAttributeTableDelegate::setModelData( QWidget *editor, QAbstractItemMode

if ( ( oldValue != newValue && newValue.isValid() ) || oldValue.isNull() != newValue.isNull() )
{
vl->beginEditCommand( tr( "Attribute changed" ) );
vl->changeAttributeValue( fid, fieldIdx, newValue, oldValue );
vl->endEditCommand();
// This fixes https://issues.qgis.org/issues/16492
QgsFeatureRequest request( fid );
request.setFlags( QgsFeatureRequest::NoGeometry );
request.setSubsetOfAttributes( QgsAttributeList( ) );
QgsFeature feature;
vl->getFeatures( request ).nextFeature( feature );
if ( feature.isValid( ) )
{
vl->beginEditCommand( tr( "Attribute changed" ) );
vl->changeAttributeValue( fid, fieldIdx, newValue, oldValue );
vl->endEditCommand();
}
}
}

@@ -251,6 +251,7 @@ void TestQgsAttributeTable::testSelected()

void TestQgsAttributeTable::testRegression15974()
{
// Test duplicated rows in attribute table + two crashes.
QString path = QDir::tempPath() + "/testshp15974.shp";
std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "polygon?crs=epsg:4326&field=id:integer" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) );
QVERIFY( tempLayer->isValid() );
@@ -281,5 +282,6 @@ void TestQgsAttributeTable::testRegression15974()
QCOMPARE( dlg->mMainView->filteredFeatureCount( ), 3 );
}


QGSTEST_MAIN( TestQgsAttributeTable )
#include "testqgsattributetable.moc"

0 comments on commit 3f9c4e5

Please sign in to comment.