grass icon indicating copy to clipboard operation
grass copied to clipboard

wxGUI/dbmgr: fix sorting newly added column values

Open tmszi opened this issue 3 years ago • 0 comments
trafficstars

Describe the bug Sorting (asc/desc) newly added column values via wxGUI dbmgr doesn't work.

To Reproduce Steps to reproduce the behavior:

  1. Launch Attribute Table Manager e.g g.gui.dbmgr geology
  2. Switch to Manage tables page (tab)
  3. Add new column e.g. area with double precision type
  4. Switch to Browse data page (tab)
  5. Right mouse click to the area column to invoke menu and choose Calculate (only numeric columns) -> Area size
  6. Left mouse click on the area column to sorting values
  7. See error
Traceback (most recent call last):
  File "/home/tomas/.local/lib/python3.9/site-packages/wx/lib/mixins/listctrl.py", line 129, in __OnColClick
    self._colSortFlag[col] = int(not self._colSortFlag[col])
IndexError: list index out of range

or

  1. Right mouse click to the area column to invoke menu and choose Sort ascending or Sort descending
  2. See error
Traceback (most recent call last):
  File "/usr/lib64/grass83/gui/wxpython/dbmgr/base.py", line 580, in OnColumnSortAsc
    self.SortListItems(col=self._col, ascending=True)
  File "/home/tomas/.local/lib/python3.9/site-packages/wx/lib/mixins/listctrl.py", line 88, in SortListItems
    self._colSortFlag[col] = ascending
IndexError: list assignment index out of range

Expected behavior Sorting (asc/desc) newly added column values via wxGUI dbmgr should be work without error message.

System description (please complete the following information):

  • Operating System: all
  • GRASS GIS version: all

Additional context

VirtualAttributeList class initialize private attribute self._colSortFlag inside listmix.ColumnSorterMixin.__init__() method, SetColumnCount() method during VirtualAttributeList class initialization, __init__() method.

https://github.com/OSGeo/grass/blob/1e0f8882da51d682982d048bb9031aa2587c0377/gui/wxpython/dbmgr/base.py#L146

If new column is added, private attribute self._colSortFlag isn't updated.

tmszi avatar Jun 14 '22 20:06 tmszi