tableListBox updateContent() crashes

Hello,

I am trying to add an item to a tableListBox component by clicking on a button as follows:

void PlaylistComponent::buttonClicked(Button* button)
{

if (button == &addButton)
{
    trackTitles.push_back("Track 3");
    
    tableComponent.updateContent();
}

}

I get the following error right after the button is clicked:

Untitled

However, when I prefill the trackTitles vector with a few items (at least 4-5 items), it works.

I spent four hours trying to figure this out. This is very frustrating for something simple like this not to work.

Please advise.

Thank you!

Hieu

I assume you are new to programming? or new to C++? I ask because you are presenting a problem where it doesn’t look like you have done any debugging. Are you familiar with the debugging? This is an important tool in the programmers toolbox, so it looks like a good time for you to learn. :slight_smile:

I figured out what the issue was. rowNumber in

paintCell(Graphics& g,
int rowNumber,
int columnId,
int width,
int height,
bool rowIsSelected)

was causing it. Didn’t realize rowNumber could go higher than what getNumRows() would return.

Thanks!

1 Like