Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#2698 closed bug (Fixed)

Column data indexes corrupted during column removal

Reported by: Ratanak Owned by:
Priority: major Milestone: 1.3.11
Component: GTK UI Version: 1.3.10
Keywords: Cc: Ratanak

Description

There is a bug in the remove_column code. At line 502 of listview.py:

# Remove from the liststore columns list
for index in column_indices:
  del self.liststore_columns[index]

column_indices is an ascending list of data indexes that a plugin uses. Normally, if a plugin only registers one status field, it loops once and there is no side effect. However, if a plugin registers multiple status fields, deleting indexes in that order will cause the liststore_columns list to be corrupted because any items after the deleted index will be shifted down in the list which would change their indexes as the loop is being executed.

Reversing the order of column_indices should fix the problem.

Change History (5)

comment:1 by Calum, 10 years ago

Thanks. Something like this then?

-for index in column_indices:
+for index in sorted(column_indices, reversed):

in reply to:  1 comment:2 by Ratanak, 10 years ago

Close. You need to assign true to the keyword as follows:

-for index in column_indices:
+for index in sorted(column_indices, reverse=True):

comment:3 by Calum, 10 years ago

Ok your mention of status_fields put me on the wrong path... it was actually an issue with columns using multiple col_types. Obviously the fix is the same but needed to create a test to cover the problem.

Fixed in 1.3-stable: [dd6e7ec490]

comment:4 by Calum, 10 years ago

Resolution: Fixed
Status: newclosed

comment:5 by Ratanak, 10 years ago

Yes, sorry. I was thinking in terms of status fields, but technically it was really about column types.

Note: See TracTickets for help on using tickets.