Bug report #10560

Wrong feature count after edit

Added by Saber Razmjooei over 5 years ago. Updated about 3 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:-
Category:Data Provider/OGR
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:18967

Description

Feature count in QGIS master (21f0b4f) reports wrong number of features after edit.
To reproduce:
  • Open a vector layer
  • Right-click on the layer from layer tree and enable Feature count (the number of features is correct at this stage)
  • Toggle editing
  • Add or delete features (number of features is still correct)
  • Save edits

Feature count resets to the original number

The bug is not in 2.2

10560_qgis-2-14-3.mp4 - Screencast (QGIS 2.14.3, Ubuntu 16.04 LTS) (876 KB) R. R., 2016-06-02 12:34 PM

qgis-rel-dev.png - Selection of QGIS rel-dev 2.14.3-26 (277 KB) Andreas Neumann, 2016-06-30 04:27 AM

qgisissue.png (169 KB) Ervin Wirth, 2016-10-04 07:11 AM


Related issues

Related to QGIS Application - Bug report #12660: Feature count on SHP file layer does not update after del... Closed 2015-04-27
Related to QGIS Application - Bug report #11007: Deleted/edited features within SHAPEFILE are still recogn... Closed 2014-08-05

Associated revisions

Revision f581e20c
Added by Martin Dobias over 5 years ago

Fix #10560 (wrong feature count)

Revision 7d7cdcd3
Added by Matthias Kuhn over 4 years ago

Repack shapefiles when saving after deleting features

  • QgsVectorDataProvider::dataChanged() will be emitted
  • QgsVectorLayer::dataChanged() will be emitted
  • Clears QgsVectorLayerCache
  • Reloads the attribute table
  • Clears the selection

Looking forward to people complaining about their lost selection...

Fix #10560
Fix #11989
Refs #8317
Refs #8822
Refs #10483
Refs #11007
Refs #7540
Refs #11398
Refs #11296

History

#1 Updated by Martin Dobias over 5 years ago

  • Assignee set to Martin Dobias

#2 Updated by Martin Dobias over 5 years ago

  • Status changed from Open to Closed

#3 Updated by Steve Lowman almost 5 years ago

  • Target version set to Version 2.6
  • Status changed from Closed to Reopened

This bug is occurring in 2.6.

#4 Updated by Giovanni Manghi almost 5 years ago

  • Affected QGIS version changed from 2.2.0 to 2.6.0
  • Status changed from Reopened to Feedback
  • Target version deleted (Version 2.6)

Steve Lowman wrote:

This bug is occurring in 2.6.

cannot confirm on qgis master, please give it a try and report back.

#5 Updated by Nyall Dawson almost 5 years ago

I can confirm this on master, when editing a shapefile.

#6 Updated by Martin Dobias over 4 years ago

  • Assignee deleted (Martin Dobias)
  • Status changed from Feedback to Open

I confirm it too - it's the same problem like in #11007 and #11989 with shapefiles that have not been repacked

#7 Updated by Jürgen Fischer over 4 years ago

  • Category set to Data Provider/OGR

#8 Updated by Saber Razmjooei over 4 years ago

  • Status changed from Open to Closed

Works fine in 2.8.2.

#9 Updated by Steve Lowman over 4 years ago

  • Status changed from Closed to Reopened

I tested it in 2.8.2. The bug still exists.
I paste a couple of copied features into the layer. The count changes from 0 to 2. All good so far.
I save the change. The count stays at 2. All correct still.
I delete one of the features. The count reduces to 1. Still good.
I save the change. The count changes back to 2. Oh dear, not so good.

#10 Updated by Giovanni Manghi over 4 years ago

  • Affected QGIS version changed from 2.6.0 to master
  • OS version deleted (7)
  • Operating System deleted (Windows)

#11 Updated by Matthias Kuhn over 4 years ago

Pull request ready.

https://github.com/qgis/QGIS/pull/2086

Most relevant discussion can be found in:
#11007

#12 Updated by Matthias Kuhn over 4 years ago

  • Status changed from Reopened to Closed

#13 Updated by Steve Lowman over 3 years ago

  • Status changed from Closed to Reopened

This bug is occurring again in 2.14.3. Feature count has been working fine for a while, but whatever the change that fixed it, it seems to have been reversed.

#14 Updated by R. R. over 3 years ago

Feature count for shape files seems to work properly here on Ubuntu 16.04 LTS (1:2.14.3+git20160529+7d7467f+24xenial). Can you provide a list of steps to reproduce the issue?

#15 Updated by Steve Lowman over 3 years ago

Yep, I'm in W10. How to reproduce this...
1. New project file.
2. New shapefile layer.
3. Check 'Show Feature Count' for new layer.
4. 'Add Features' tool, digitise some features, e.g. 2 features. (Feature Count updates correctly - reads '2').
5. Save Layer Edits. (Feature Count stays correct - reads '2').
6. Digitise one more feature, and save layer edits. (Feature Count still correct - reads '3').
7. Select and delete one of your features. (Feature Count reduces correctly - reads '2').
8. Save Layer Edits. (Feature Count incorrectly reverts to previous value - reads '3').

#16 Updated by R. R. over 3 years ago

Hi Steve, thanks for your reply. I can't confirm this issue on Ubuntu 16.04 LTS (see screencast).

#17 Updated by R. R. over 3 years ago

Steve Lowman wrote:

8. Save Layer Edits. (Feature Count incorrectly reverts to previous value - reads '3').

I can confirm this on Win7 (QGIS 2.14.3)!

Related: #14859 - Feature count issue (PostGIS view)

#18 Updated by Andreas Neumann over 3 years ago

I just tested this with a shapefile on Windows 7 with QGIS 2.15 (master) and QGIS 2.14 (#843d17e ) and aren't able to reproduce this issue.

@Reinhard and/or Steve: can you please test with #843d17e - you can install it using the OSGeo4W installer (http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe) by chosing "QGIS Rel Dev" in the "Desktop" section.

#19 Updated by Giovanni Manghi over 3 years ago

  • Status changed from Reopened to Feedback

#20 Updated by Giovanni Manghi over 3 years ago

  • Status changed from Feedback to Closed
  • Resolution set to fixed/implemented

this is very likely related to #11007

the issue has been solved in master and backported to the development branch of 2.14

#21 Updated by R. R. over 3 years ago

I've done the steps above in QGIS 2.15 master 600ff4f and 'Show Feature Count' works as expected.

(Win7)

#22 Updated by Ervin Wirth about 3 years ago

  • Status changed from Closed to Reopened
  • File qgisissue.png added

The problem still exist with 2.16.2 after removing some features with PyQGIS codelines and commit changes.
Windows 7 x64.

#23 Updated by Even Rouault about 3 years ago

  • Status changed from Reopened to Feedback

@Ervin, could you provide a self contained script + dataset that reproduces the issue ?

#24 Updated by Matthias Kuhn about 3 years ago

  • Status changed from Feedback to Closed

@Ervin, make sure you use the layer.add/remove/etcFeature() methods and not layer.dataProvider().add/remove/etcFeature() methods.

Will close this until someone can provide a script/data to reproduce.

Also available in: Atom PDF