I am working with refreshComponentForCell in TableListBoxModel in an attempt to load custom components in various cells. These custom components are being stored in an OwnedArray of a class that keeps it’s own OwnedArray that may store these custom components.
The problem I’m running into is that when scrolling through the page, my refreshComponentForCell method checks to see if the cell should be empty, and whether it is or not, and if there’s a component where it shouldn’t be, it attempts to clear it out. Fairly simple when creating these components on the heap in the refreshComponentForCell method, since I can just delete them. But what I am struggling with is reusing components already allocated elsewhere (in my OwnedArray), since I would like to just point to them as the component and then just clear that out when not needed (so that they are not deleted). but it seems if I set existingComponentToBeUpdated to nullptr and return it, the model does not properly point to 0 any more - it seems the component stays and is reused.
Is there a better way of handling a table in which components that have already been allocated are used, and not necessarily deleted when no longer needed (specifically so when scrolling)?