TrayIcon - Does not refresh popup menu after removing menuitems
Original Reporter info from Mantis: Hansaplast
-
Reporter name: Hans Luijten
Original Reporter info from Mantis: Hansaplast
- Reporter name: Hans Luijten
Description:
When removing items from a TrayIcon PopupMenu, these items will not disappear (visually) from the menu. When clicking on such a removed item, the application crashes so I assume the TMenuItem object has been removed/destroyed correctly, but there was no visual update of the popup menu.
When just updating a caption, this does refresh just fine.
Steps to reproduce:
See attached example project;
At start, the menu has one "fixed" item (caption=This Item Stays).
Click "Add Menu Item" adds dynamically a TMenuItem with caption 'Test Menu Item' and Tag=-1 (so we can identify which ones to remove later on).
Click TrayIcon and you'll see both MenuItems correctly - so adding MenuItems is not a problem.
Click "Remove Dynamic MenuItems" to remove the newly added MenuItem.
Click TrayIcon again: the menuitem is still visible.
Clicking the MenuItem = crash (suggesting the TMenuItem object is gone indeed).
Under Linux (GTK) and Windows this works perfectly fine. Not under Cocoa though.
I've tested a silly "TrayIcon1.Hide, make changes to the menu, and TrayIcon1.Show" trick, but in Cocoa that actually generates additional TrayIcons for each time this is done (eg. "Hide" doesn't seem to work, and "Show" only creates and additional one).
.
The TrayIcon1.InternalUpdate trick used with Carbon doesn't seem to do anything under Cocoa.
Note:
For testing I've added a button to change the caption of the dynamically added MenuItems (Add 'x' in front of dynamic MenuItems). This does work correctly, obviously, removed menuItems still remain visible, but the caption of those will naturally not be updated.
Additional information:
Lazarus 2.1.0 r59646M FPC 3.0.4 x86_64-darwin-cocoa (alpha)
MacOS 10.1.4.1
Mantis conversion info:
- Mantis ID: 34602
- OS: macOS
- OS Build: 10.14
- Build: r59646M
- Platform: Mac
- Version: 2.1 (SVN)
- Fixed in revision: 59752 (#eb70a1af)
- Monitored by: » Hansaplast (Hans Luijten)