Opened 3 years ago

Closed 3 years ago

Last modified 3 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 follow-up: Changed 3 years ago by Cas

Thanks. Something like this then?

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

comment:2 in reply to: ↑ 1 Changed 3 years ago by Ratanak

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 Changed 3 years ago by Cas

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 Changed 3 years ago by Cas

  • Resolution set to Fixed
  • Status changed from new to closed

comment:5 Changed 3 years ago by Ratanak

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.