Skip to content

Incorrect SelectedFeatureCount in QgsVectorLayer after SelectFeatureByIds. #61604

@grig27

Description

@grig27

What is the bug or the crash?

If you excecute Python command "layer.selectByIds([id])" where layer is QgsVectorLayer and id not exists in layer, then the result of command "layer.selectedFeatureCount()" will be 1 instead of 0!

I checked on version from 3.16 to 3.40.

Steps to reproduce the issue

excecute Python command
layer.selectByIds([1111222222]) '1111222222 is not exists
cnt = layer.selectedFeatureCount() ' cnt is not 0

Versions

from 3.16 to 3.40

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugEither a bug report, or a bug fix. Let's hope for the latter!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions