I am replacing the DialogWindow close button using the LookAndFeel class. I got an exception when a key was pressed and I found that there was a bad key listener in my dialog window. I checked and I think the problem is in the code below. The shortcut is deleted but not removed from the array and that causes parentHierarchyChanged() to add invalid key listener…
void Button::clearShortcuts()
{
for (int i = shortcuts.size(); --i >= 0;)
{
KeyPress* const k = (KeyPress*) shortcuts.getUnchecked(i);
delete k;
}
parentHierarchyChanged();
}
adding
shortcuts.remove(i);
before the delete solves the problem…
