Android: Make platform menu more robust

Don't crash and lock up the whole device when people try to
remove menu items that don't exist.

Task-number: QTBUG-34246
Change-Id: I4396d252c5af93e021c9e218dbab7c0e7f190d9d
Reviewed-by: BogDan Vatra <bogdan@kde.org>
This commit is contained in:
Paul Olav Tvete 2013-10-22 17:57:46 +02:00 committed by The Qt Project
parent a83983d861
commit bd3f3f31bf

View File

@ -67,9 +67,11 @@ void QAndroidPlatformMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatform
void QAndroidPlatformMenu::removeMenuItem(QPlatformMenuItem *menuItem)
{
QMutexLocker lock(&m_menuItemsMutex);
m_menuItems.erase(qFind(m_menuItems.begin(),
m_menuItems.end(),
static_cast<QAndroidPlatformMenuItem *>(menuItem)));
PlatformMenuItemsType::iterator it = qFind(m_menuItems.begin(),
m_menuItems.end(),
static_cast<QAndroidPlatformMenuItem *>(menuItem));
if (it != m_menuItems.end())
m_menuItems.erase(it);
}
void QAndroidPlatformMenu::syncMenuItem(QPlatformMenuItem *menuItem)