File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -197,10 +197,8 @@ class QgsExpressionContextScope
197
197
198
198
void setFeature( const QgsFeature& feature );
199
199
200
- /** Convenience function for setting a fields for the scope. Any existing
201
- * fields set by the scope will be overwritten.
202
- * @param fields fields for scope
203
- */
200
+ void removeFeature();
201
+
204
202
void setFields( const QgsFields& fields );
205
203
};
206
204
Original file line number Diff line number Diff line change @@ -269,9 +269,19 @@ class CORE_EXPORT QgsExpressionContextScope
269
269
/* * Convenience function for setting a feature for the scope. Any existing
270
270
* feature set by the scope will be overwritten.
271
271
* @param feature feature for scope
272
+ * @see removeFeature()
273
+ * @see feature()
272
274
*/
273
275
void setFeature ( const QgsFeature& feature ) { mHasFeature = true ; mFeature = feature; }
274
276
277
+ /* *
278
+ * Removes any feature associated with the scope.
279
+ * @note added in QGIS 3.0
280
+ * @see setFeature()
281
+ * @see hasFeature()
282
+ */
283
+ void removeFeature () { mHasFeature = false ; mFeature = QgsFeature (); }
284
+
275
285
/* * Convenience function for setting a fields for the scope. Any existing
276
286
* fields set by the scope will be overwritten.
277
287
* @param fields fields for scope
Original file line number Diff line number Diff line change @@ -437,6 +437,9 @@ void TestQgsExpressionContext::setFeature()
437
437
scope.setFeature ( feature );
438
438
QVERIFY ( scope.hasFeature () );
439
439
QCOMPARE ( scope.feature ().id (), 50LL );
440
+ scope.removeFeature ();
441
+ QVERIFY ( !scope.hasFeature () );
442
+ QVERIFY ( !scope.feature ().isValid () );
440
443
441
444
// test setting a feature in a context with no scopes
442
445
QgsExpressionContext emptyContext;
You can’t perform that action at this time.
0 commit comments