Skip to content

Commit ebfc874

Browse files
committed
[dualview] Fix crash when adding columns with feature form open
1 parent 37f53b0 commit ebfc874

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/gui/attributetable/qgsdualview.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ void QgsDualView::init( QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, QgsDista
6565
connect( layer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
6666
connect( layer, SIGNAL( beforeCommitChanges() ), this, SLOT( editingToggled() ) );
6767
connect( layer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
68+
connect( layer, SIGNAL( attributeAdded( int ) ), this, SLOT( editingToggled() ) );
69+
connect( layer, SIGNAL( attributeDeleted( int ) ), this, SLOT( editingToggled() ) );
6870

6971
initLayerCache( layer );
7072
initModels( mapCanvas );
@@ -235,7 +237,7 @@ void QgsDualView::initModels( QgsMapCanvas* mapCanvas )
235237
mFeatureListModel = new QgsFeatureListModel( mFilterModel, mFilterModel );
236238
}
237239

238-
void QgsDualView::on_mFeatureList_currentEditSelectionChanged( const QgsFeature &feat )
240+
void QgsDualView::on_mFeatureList_currentEditSelectionChanged( QgsFeature &feat )
239241
{
240242
if ( !feat.isValid() )
241243
return;
@@ -249,6 +251,9 @@ void QgsDualView::on_mFeatureList_currentEditSelectionChanged( const QgsFeature
249251
mAttributeEditorLayout->removeWidget( mAttributeDialog->dialog() );
250252
}
251253

254+
if ( feat.attributes().count() != mLayerCache->layer()->pendingFields().count() )
255+
mLayerCache->featureAtId( feat.id(), feat );
256+
252257
mAttributeDialog = new QgsAttributeDialog( mLayerCache->layer(), new QgsFeature( feat ), true, mDistanceArea, this, false );
253258
mAttributeEditorLayout->addWidget( mAttributeDialog->dialog() );
254259
mAttributeDialog->dialog()->setVisible( true );

src/gui/attributetable/qgsdualview.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class GUI_EXPORT QgsDualView : public QStackedWidget, private Ui::QgsDualViewBas
171171
*
172172
* @param feat The newly visible feature
173173
*/
174-
void on_mFeatureList_currentEditSelectionChanged( const QgsFeature &feat );
174+
void on_mFeatureList_currentEditSelectionChanged( QgsFeature& feat );
175175

176176
void previewExpressionBuilder();
177177

0 commit comments

Comments
 (0)