From 1880fba971ed8ae8e813829ff3668132371e88a7 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 29 Jul 2019 14:16:00 +0200 Subject: Android: Fix QMenu on 64 bit The platform menu tags in Qt are actually the pointers, so they are 64-bit values when the build is 64 bit. Since menu IDs in Android are 32-bit ints, we cannot cast back and forth like we do. To fix this, we add a separate hash of menu IDs to allow mapping between Java and C++. For easier book-keeping, we add the hashes to the menu bar and menu classes, so that we can easily recycle old menu IDs when they are no longer in use. Note that overriding the tag on the menus by calling setTag() will not work, since Qt Widgets will later override it again by setting it back to the menu's pointer. [ChangeLog][Android] Fixed an issue where menus would not work on 64 bit builds. Task-number: QTBUG-76036 Change-Id: Icaa1d235d4166331669139251656ea0159e85195 Reviewed-by: Frederik Gladhorn --- src/plugins/platforms/android/qandroidplatformmenu.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/plugins/platforms/android/qandroidplatformmenu.h') diff --git a/src/plugins/platforms/android/qandroidplatformmenu.h b/src/plugins/platforms/android/qandroidplatformmenu.h index 47e650f2d7..b1d6a88787 100644 --- a/src/plugins/platforms/android/qandroidplatformmenu.h +++ b/src/plugins/platforms/android/qandroidplatformmenu.h @@ -73,6 +73,8 @@ public: QPlatformMenuItem *menuItemAt(int position) const override; QPlatformMenuItem *menuItemForTag(quintptr tag) const override; + QPlatformMenuItem *menuItemForId(int menuId) const; + int menuId(QPlatformMenuItem *menuItem) const; PlatformMenuItemsType menuItems() const; QMutex *menuItemsMutex(); @@ -84,6 +86,9 @@ private: bool m_enabled; bool m_isVisible; QMutex m_menuItemsMutex; + + int m_nextMenuId = 0; + QHash m_menuHash; }; QT_END_NAMESPACE -- cgit v1.2.3