Fix crash when an extension adds a command in a non-existent menu group (fix #3835)

This commit is contained in:
David Capello 2023-05-01 10:50:53 -03:00
parent bfe4669c0e
commit 4d3575f4ce

View File

@ -650,8 +650,15 @@ void AppMenus::removeMenuGroup(const std::string& groupId)
void AppMenus::addMenuItemIntoGroup(const std::string& groupId,
std::unique_ptr<Widget>&& menuItem)
{
GroupInfo& group = m_groups[groupId];
auto it = m_groups.find(groupId);
if (it == m_groups.end()) {
LOG(ERROR, "MENU: An extension tried to add a command (%s) in a non-existent group (%s)\n",
menuItem->text().c_str(), groupId.c_str());
menuItem.release();
return;
}
GroupInfo& group = it->second;
Menu* menu = group.menu;
ASSERT(menu);