summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/qandroidplatformmenu.h
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2019-07-29 14:16:00 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2019-08-08 07:06:05 +0200
commit1880fba971ed8ae8e813829ff3668132371e88a7 (patch)
tree9acc8160a35ae17065fd5f3b6d694a24ff02768f /src/plugins/platforms/android/qandroidplatformmenu.h
parent36cc171b9314bf77fc84d4273dceb6264aef7134 (diff)
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 <frederik.gladhorn@qt.io>
Diffstat (limited to 'src/plugins/platforms/android/qandroidplatformmenu.h')
-rw-r--r--src/plugins/platforms/android/qandroidplatformmenu.h5
1 files changed, 5 insertions, 0 deletions
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<int, QPlatformMenuItem *> m_menuHash;
};
QT_END_NAMESPACE