Bug report #19531
Running extract by attribute in a model and providing a non-existent selection attribute causes QGIS to crash
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | Processing/Modeller | ||
Affected QGIS version: | 3.3(master) | Regression?: | Yes |
Operating System: | Windows 10 | Easy fix?: | Yes |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | Yes | Copied to github as #: | 27358 |
Description
QGIS crashes if you use the "Extract by attribute" algorithm in a model in QGIS processing, and specify a field for the selection attribute which does not exist in the provided layer. A model and sample layer which demonstrates this is attached. This behaviour is only possible in a model (or in batch mode), since the field is populated by a drop-down list when run directly as an algorithm.
The algorithm id is native:extractbyattribute. I think it is a regression because while in 2.18 it would also not give an informative exception (it produces an empty layer), it did not crash QGIS.
I suspect that this bug can be fixed by adding something like:
if (idx == -1) throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "FIELD" ) ) );
after https://github.com/qgis/QGIS/blame/master/src/analysis/processing/qgsalgorithmextractbyattribute.cpp#L105, but I haven't been able to test that.
Associated revisions
[processing] Fix crash in extract by attribute when field name does not exist
Fixes #19531
History
#1 Updated by Nyall Dawson over 6 years ago
- % Done changed from 0 to 100
- Status changed from Open to Closed
Applied in changeset qgis|4acef1efbf0c4bae01fc75915ad8374955af9fa7.