Tray menu on Mac Lion crashes
Original Reporter info from Mantis: SpongeBob
-
Reporter name: SpongeBob
Original Reporter info from Mantis: SpongeBob
- Reporter name: SpongeBob
Description:
Tray menu on Mac Lion crashes when you click on a menu item with segfault (access violation). This was reported in #18989 (closed) but discarded. The bug is in LCL and not in Lion as it was believed.
Additional information:
The error appears to be in parameters (order) in callback:
In carbontrayicon.inc:
class procedure TPrivateCocoaCarbonTrayIcon.HandleMenuItemClick(_self: lobjc.id;
_cmd: SEL; sender: lobjc.id); cdecl; //static;
var
AMenuItem: NSMenuItem;
LCLMenu: TMenuItem;
begin
//AMenuItem := NSMenuItem.CreateWithHandle(sender); // causes crash on Lion
AMenuItem := NSMenuItem.CreateWithHandle(lobjc.id(_cmd)); //works ok on 10.5.5 and Lion 10.7
LCLMenu := TMenuItem(PtrInt(AMenuItem.Tag())); // AMenuItem.Tag() causes segfault when "sender" is used.
Also I have found another problem with tray icon - if you set TrayIcon1.Visible:=true in designer, the tray icon will show up, however the menu will never popup. A workaround is to set TrayIcon1.Visible:=true in Form1.OnCreate. If someone can fix this, would be great.