Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting/Deleting in attribute table does not work correctly for layers with no attributes (crashes in one situation!) #14537

Closed
qgib opened this issue Dec 12, 2011 · 10 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption Digitizing Related to feature digitizing map tools or functionality
Milestone

Comments

@qgib
Copy link
Contributor

qgib commented Dec 12, 2011

Author Name: Alister Hood (@AlisterH)
Original Redmine Issue: 4636
Affected QGIS version: master
Redmine category:digitising


Create a vector layer with no attribute columns. (This is possible with the "new memory layer" plugin - I'm not sure what other formats support layers with no attributes. I guess you could do it with csv + csvt).

  1. Open the attribute table
  2. Click the edit button
  3. Add or select and delete a feature using the digitising tools in the QGIS map window, and:
  • The attribute table will be refreshed as it should (i.e. the features will appear or disappear).
  1. Select a feature by using the selection tools in the map window, and:
  • The feature will not be highlighted in the attribute table as it is when you select a feature in a layer that has an attribute column (i.e. selected row number in bold, and looking like a depressed button or something).
  1. Select a feature by clicking on a row in the attribute table, and:
  • The selected feature will neither be highlighted in the attribute table nor in the map canvas. Is it selected, or not?
  1. Click the button in the attribute table to delete the feature:
  • You will be asked to confirm whether you really want to delete (1) feature (so it looks like the feature was selected). But:
  1. say yes, you do want to delete the feature, and:
  • The feature will not be deleted. It will still be visible in the map canvas and the attribute table (so maybe it wasn't really selected).
  1. Click on another row in the attribute table.
  2. Click the button in the attribute table to delete the feature.
  3. say yes, you do want to delete the feature, and:
  • QGIS will freeze, using 100% of a CPU. You will need to kill it.
  1. Try steps 1 to 9 again, but instead of clicking the button in the attribute table in step 7, use the button in the main digitizing toolbar in the QGIS map window.
  • Now at step 9 the selected feature is magically highlighted in the map window.
  1. Click another row in the attribute table to selected a different feature.
  • The previously selected feature remains highlighted in the map window.
  1. Click the button in the digitizing toolbar to delete the selected feature
  • The highlighted feature is deleted.
  1. Delete some more features this way.
  • If you took note of the order in which you created the features, I think you'll notice that they are not deleted in the order that you expect. But the memory layer provider does keep the features in the order that you expect if there is an attribute column.

@qgib
Copy link
Contributor Author

qgib commented Dec 12, 2011

Author Name: Alister Hood (@AlisterH)


Sorry, the automatic numbering didn't work as I expected:

  1. Create a vector layer with no attribute columns. (This is possible with the "new memory layer" plugin - I'm not sure what other formats support layers with no attributes. I guess you could do it with csv + csvt).
  2. Open the attribute table
  3. Click the edit button
  4. Add or select and delete a feature using the digitising tools in the QGIS map window, and:
  • The attribute table will be refreshed as it should (i.e. the features will appear or disappear).
  1. Select a feature by using the selection tools in the map window, and:
  • The feature will not be highlighted in the attribute table as it is when you select a feature in a layer that has an attribute column (i.e. selected row number in bold, and looking like a depressed button or something).
  1. Select a feature by clicking on a row in the attribute table, and:
  • The selected feature will neither be highlighted in the attribute table nor in the map canvas. Is it selected, or not?
  1. Click the button in the attribute table to delete the feature:
  • You will be asked to confirm whether you really want to delete (1) feature (so it looks like the feature was selected). But:
  1. say yes, you do want to delete the feature, and:
  • The feature will not be deleted. It will still be visible in the map canvas and the attribute table (so maybe it wasn't really selected).
  1. Click on another row in the attribute table.
  2. Click the button in the attribute table to delete the feature.
  3. say yes, you do want to delete the feature, and:
  • QGIS will freeze, using 100% of a CPU. You will need to kill it.
  1. Try steps 1 to 9 again, but instead of clicking the button in the attribute table in step 7, use the button in the main digitizing toolbar in the QGIS map window.
  • Now at step 9 the selected feature is magically highlighted in the map window.
  1. Click another row in the attribute table to selected a different feature.
  • The previously selected feature remains highlighted in the map window.
  1. Click the button in the digitizing toolbar to delete the selected feature
  • The highlighted feature is deleted.

@qgib
Copy link
Contributor Author

qgib commented Dec 16, 2011

Author Name: Giovanni Manghi (@gioman)


  • fixed_version_id was configured as Version 1.7.4

@qgib
Copy link
Contributor Author

qgib commented Dec 22, 2011

Author Name: Jürgen Fischer (@jef-n)


  • version was configured as master
  • crashes_corrupts_data was configured as 1

@qgib
Copy link
Contributor Author

qgib commented Dec 23, 2011

Author Name: Giovanni Manghi (@gioman)


Hi Alister,

I made a test following the steps you describe and the memory layer plugin, and on both Windows and Linux (gnome) I found differences and I wasn't able to replicate all your steps. Please have a look here and let me know if/what I have done wrong.

steps 1-4: the table of attributes shows just the first "pseudo" column with the row id and nothing more. From the canvas with the editing tools is possible to add/remove features and this will reflect correctly in the (empty) table of attributes.

step 5: right, selecting a feature in the canvas does not selects anything in the table of attributes. Question: what should be selected in the table of attributes? is empty. I don't see anything strange here.

steps 6-8: in my tests clicking on a row id does NOT select anything, in fact if I first click on "deselect features from all layers" and then try to select a feature using the row id in the table of attributes and subsequently clicking on "delete selected features" I always get a "Delete 0 feature(s)?" that as expected does nothing.

On the other hand "delete selected features" works as expected after selecting features from the canvas.

steps 9-11: cannot replicate this behavior because as I said I'm not able to select anything from the table of attributes, as expected I would say.

steps 12-14: same as 9-11

I'm not sure I have done the test correctly, probably I have not understand well your description. Eventually can you make a screencast?


  • status_id was changed from Open to Feedback

@qgib
Copy link
Contributor Author

qgib commented Jan 9, 2012

Author Name: Alister Hood (@AlisterH)


OK, here is a screencast.
http://dl.dropbox.com/u/24564149/%234636.avi

The behaviour does depend on what order you do things in (I can get the same result as you if I do things differently), and it seems like some aspects of this have changed slightly in current trunk. But the essence is the same:

  • in some circumstances features can be selected but not appear to be selected.
  • in some circumstances it freezes when you try to select these features.

Note that this computer is quad core, hence the 25% CPU use by QGIS when it freezes.
Also note the inconsistencies in how many features the attribute table title bar claims are selected (compare with the main window status bar, the map, and the actual attribute table, which always shows none selected).

@qgib
Copy link
Contributor Author

qgib commented Jan 9, 2012

Author Name: Alister Hood (@AlisterH)


Giovanni Manghi wrote:

...
step 5: right, selecting a feature in the canvas does not selects anything in the table of attributes. Question: what should be selected in the table of attributes? is empty. I don't see anything strange here.
...

The table doesn't have any cells to show as selected, but the row-header (or whatever it is called) should show as selected. It should look like the attached image.


  • 4165 was configured as attribute_table.PNG

@qgib
Copy link
Contributor Author

qgib commented Jan 11, 2012

Author Name: Jürgen Fischer (@jef-n)


Fixed in changeset "d43c89ae6a1cbdc9d957ea5663579ad13950e3b2".


  • status_id was changed from Feedback to Closed
  • done_ratio was changed from 0 to 100

@qgib
Copy link
Contributor Author

qgib commented Jan 11, 2012

Author Name: Alister Hood (@AlisterH)


Great, I think that fixed another much more common (but not dangerous) bug, too. Thanks.

I think there could be two minor improvements:

  1. Try this: create a new memory layer without adding any attribute columns (or open a shapefile with no attributes), right-click on it and save-as a new shape file.
    OR
    Open any shape file or memory layer which does have attributes, right-click on it and save-as a new shape file, selecting the option to "Skip attribute creation".
    RESULT: the new shape file will have an attribute field called "FID". In both cases I don't think it should.

  2. Is there really a need to hide the Feature ID column if the layer has attribute fields?

  • I can imagine some people might like to see it.
  • Having it hidden sometimes and visible other times will be a little bit confusing.

@qgib
Copy link
Contributor Author

qgib commented Jan 12, 2012

Author Name: Jürgen Fischer (@jef-n)


Alister Hood wrote:

Great, I think that fixed another much more common (but not dangerous) bug, too. Thanks.

No problem.

I think there could be two minor improvements:

  1. Try this: create a new memory layer without adding any attribute columns (or open a shapefile with no attributes), right-click on it and save-as a new shape file.
    OR
    Open any shape file or memory layer which does have attributes, right-click on it and save-as a new shape file, selecting the option to "Skip attribute creation".
    RESULT: the new shape file will have an attribute field called "FID". In both cases I don't think it should.

That's something OGR does internally as it doesn't fully support shapefiles without DBF (see http://www.gdal.org/ogr/drv_shapefile.html). OGR only support those readonly.

  1. Is there really a need to hide the Feature ID column if the layer has attribute fields?
  • I can imagine some people might like to see it.
  • Having it hidden sometimes and visible other times will be a little bit confusing.

IMHO layers without any attributes are already an edge case and using the attributetable on attributeless layers even tops that ;)

@qgib
Copy link
Contributor Author

qgib commented Jan 12, 2012

Author Name: Alister Hood (@AlisterH)


Jürgen Fischer wrote:

Alister Hood wrote:

Great, I think that fixed another much more common (but not dangerous) bug, too. Thanks.

No problem.

I think there could be two minor improvements:

  1. Try this: create a new memory layer without adding any attribute columns (or open a shapefile with no attributes), right-click on it and save-as a new shape file.
    OR
    Open any shape file or memory layer which does have attributes, right-click on it and save-as a new shape file, selecting the option to "Skip attribute creation".
    RESULT: the new shape file will have an attribute field called "FID". In both cases I don't think it should.

That's something OGR does internally as it doesn't fully support shapefiles without DBF (see http://www.gdal.org/ogr/drv_shapefile.html). OGR only support those readonly.

Oh, I see. I was wondering why I could edit features in shape files with no attributes, but not add attributes, or add or delete features :)

  1. Is there really a need to hide the Feature ID column if the layer has attribute fields?
  • I can imagine some people might like to see it.
  • Having it hidden sometimes and visible other times will be a little bit confusing.

IMHO layers without any attributes are already an edge case and using the attributetable on attributeless layers even tops that ;)

Fair enough.

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Digitizing Related to feature digitizing map tools or functionality Crash/Data Corruption labels May 24, 2019
@qgib qgib added this to the Version 1.7.4 milestone May 24, 2019
@qgib qgib closed this as completed May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption Digitizing Related to feature digitizing map tools or functionality
Projects
None yet
Development

No branches or pull requests

1 participant