@@ -98,7 +98,9 @@ bool QgsFeatureAction::viewFeatureForm( QgsHighlight *h )
98
98
99
99
QgsAttributeDialog *dialog = newDialog ( true );
100
100
dialog->setHighlight ( h );
101
- dialog->show (); // will also delete the dialog on close (show() is overridden)
101
+ // delete the dialog when it is closed
102
+ dialog->setAttribute ( Qt::WA_DeleteOnClose );
103
+ dialog->show ();
102
104
103
105
return true ;
104
106
}
@@ -108,24 +110,29 @@ bool QgsFeatureAction::editFeature( bool showModal )
108
110
if ( !mLayer )
109
111
return false ;
110
112
111
- QgsAttributeDialog *dialog = newDialog ( false );
112
-
113
- if ( !mFeature ->isValid () )
114
- dialog->setIsAddDialog ( true );
115
-
116
113
if ( showModal )
117
114
{
118
- dialog->setAttribute ( Qt::WA_DeleteOnClose );
119
- int rv = dialog->exec ();
115
+ QScopedPointer<QgsAttributeDialog> dialog ( newDialog ( false ) );
116
+
117
+ if ( !mFeature ->isValid () )
118
+ dialog->setIsAddDialog ( true );
120
119
120
+ int rv = dialog->exec ();
121
121
mFeature ->setAttributes ( dialog->feature ()->attributes () );
122
122
return rv;
123
123
}
124
124
else
125
125
{
126
- dialog->show (); // will also delete the dialog on close (show() is overridden)
127
- }
126
+ QgsAttributeDialog* dialog = newDialog ( false );
127
+
128
+ if ( !mFeature ->isValid () )
129
+ dialog->setIsAddDialog ( true );
128
130
131
+ // delete the dialog when it is closed
132
+ dialog->setAttribute ( Qt::WA_DeleteOnClose );
133
+ dialog->show ();
134
+ }
135
+
129
136
return true ;
130
137
}
131
138
@@ -193,6 +200,8 @@ bool QgsFeatureAction::addFeature( const QgsAttributeMap& defaultAttributes, boo
193
200
else
194
201
{
195
202
QgsAttributeDialog *dialog = newDialog ( false );
203
+ // delete the dialog when it is closed
204
+ dialog->setAttribute ( Qt::WA_DeleteOnClose );
196
205
dialog->setIsAddDialog ( true );
197
206
dialog->setEditCommandMessage ( text () );
198
207
@@ -201,12 +210,11 @@ bool QgsFeatureAction::addFeature( const QgsAttributeMap& defaultAttributes, boo
201
210
if ( !showModal )
202
211
{
203
212
setParent ( dialog ); // keep dialog until the dialog is closed and destructed
204
- dialog->show (); // will also delete the dialog on close (show() is overridden)
213
+ dialog->show ();
205
214
mFeature = nullptr ;
206
215
return true ;
207
216
}
208
217
209
- dialog->setAttribute ( Qt::WA_DeleteOnClose );
210
218
dialog->exec ();
211
219
}
212
220
0 commit comments