Cocoa/Menu: fix the crash when insert a hidden separator after a visible MenuItem, introduced by e762d9b, see also #41028

This commit is contained in:
rich2014 2024-09-09 16:07:54 +08:00
parent aa2b041e48
commit fd73e63c77

View File

@ -219,7 +219,9 @@ begin
MenuObj := NSObject(AMenuItem.Handle);
if MenuObj.isKindOfClass(NSMenuItem) then begin
item := NSMenuItem(MenuObj);
Parent.insertItem_atIndex(NSMenuItem(item), idx)
if idx > Parent.numberOfItems then
idx:= Parent.numberOfItems;
Parent.insertItem_atIndex(NSMenuItem(item), idx);
end
else if MenuObj.isKindOfClass(NSMenu) then
begin