Using “tip” as of Thursday 26th 2012 on Mac OS X (Lion) - although the bug should be independent of platform.
Note: This is only a bug if, as the docs state, TableListBox can have a “unique” custom component on each “cell”.
Issue: “Ghost” components show up on cells.
Steps to repro:
- Create a TableListBox with more rows than it can display (so that it adds a scroll bar).
- Implement “refreshComponentForCell()” and return a custom component “only for row one, column one”
- scroll down
Results: The row that was offscreen, which now, after scrolling, it shows up, contains the custom component of the very first row.
Expected results: The only row that should have a custom component is the very first one.
Detailed explanation: Currently the code has an optimization that assumes that for a given columnID, all of the rows will have the same custom component. When scrolling, JUCE simply reuses components that were previously visible and now they are not. The problem with this is that when scrolling, the update ends up calling “refreshComponentForCell()” reusing a row that contains a component, passing the pointer to the component of the first row. My code catches that and asserts, and returns nullptr, but even then, the row displays the component of the first row.
The current code works fine if all of the rows for that column id use the same component, it simply needs to be updated with the values of the new row. When the components on each row are “unique”, this whole scheme fails.