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);
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?