Deleting rows in table list box

Hi, I was trying to delete rows from table with certain attribute value. I was trying to do so in the TableListBoxTutorial. But the following code raises an exception (read acces violation in juce_LinkedListPointer.h inline ObjectType* get() const noexcept { return item; }):

while (dataList->getChildByAttribute("Groups", "2") != nullptr)
        dataList->removeChildElement(dataList->getChildByAttribute("Groups", "2"), false);

Does anyone has an idea what might be the issue?

Not sure, what triggers that, but two remarks:
Are you holding on to the XmlElements? Since they are owned by the tree, I think you should call removeChildElement with “shouldDeleteTheChild” = true.
And you can rewrite the loop, making the lookup safe:

while (auto* child = dataList->getChildByAttribute ("Groups", "2"))
        dataList->removeChildElement (child, true);

If the crash persists, can you post the full call stack, that led to the crash?

I rewrote the loop as you suggested and it’s working now. So thank you very much. I have one more question, when I remove the child element and update and repaint the table, the rows are still visible (not the data, just the rows). Am I doing something wrong or do I have to do something else in order to delete the rows from the table?

By ‘update and repaint’ do you mean you are calling ListBox::updateContent()?

I’m calling both updateContent() and repaint(), in this order.

not like using xml to represent a table… A vector with struct is make sense for…

I’m new to JUCE so I followed the TableListBoxTutorial and the xml representation of the data worked for me so far.