ListBox::createSnapshotOfSelectedRows firstRow calculation bug?


I have a listbox with draggable items and I noticed that, when viewing the top of the list and initiating a drag operation, firstRow was always returning -1 instead of 0. This went unnoticed because the subsequent for loop adds 2 to the index (not sure why). However, this fails when I try to drag and drop the very last row of my listbox (since the for loop only searchs up to the second to last row).

I changed the firstRow call to:

const int firstRow = getRowContainingPosition (0, headerComponent->getHeight());

And the for loop to

for (int i = getNumRowsOnScreen() + 1/*2*/; --i >= 0;)

And this allowed me to have correct behavior, but I do not know if this is a correct fix for the problem (or if anyone else is seeing this same issue).

Submitted for the consideration of JUCEier programmers than myself.


Good point about the firstRow - I'll fix that.

I think the loop code is correct though, since it could need to use up to 2 rows more than are on-screen if the top + bottom are both half-obscured (?)