Kraku
1
The following code crashes when popup menu is visible and I exit the software in OSX. How to use PopupMenus so they don’t crash?
void MyClass::mouseDown(const MouseEvent& e)
{
PopupMenu pop_up_menu;
pop_up_menu.addItem (1, “item 1”);
pop_up_menu.addItem (2, “item 2”);
const int result = pop_up_menu.show();
}
reuk
2
Rather than using the modal show
function, try using showMenuAsync
.
Kraku
3
Seems to work. I did the following without crashes:
PopupMenu popup_menu;
popup_menu.addItem("Add row", []() { });
popup_menu.addItem("Delete row", []() { });
popup_menu.addSeparator();
popup_menu.addItem("Add column", []() { });
popup_menu.addItem("Delete column", []() { });
popup_menu.showMenuAsync(juce::PopupMenu::Options());
Just in case I added this into application’s systemRequestQuit():
PopupMenu::dismissAllActiveMenus();
Is that dismissAllActiveMenus() good to have there or is it not needed?