UPD: optimize memory release in ContextMenu on macOS

This commit is contained in:
rich2014 2024-10-11 19:01:41 +08:00
commit cbb4b2fa5b
2 changed files with 12 additions and 8 deletions

View file

@ -844,6 +844,8 @@ begin
cocoaItem:= NSMenuItem( lclMenu.Items[menuIndex].Handle );
cocoaItem.setView( menuView );
menuView.release;
end;
class procedure uDarwinFinderUtil.drawTagName( const tagName: NSString;

View file

@ -767,14 +767,16 @@ begin
end;
filepath:= Files[0].FullPath;
// Free previous created menu
FreeAndNil(ShellContextMenu);
// Create new context menu
ShellContextMenu:= TShellContextMenu.Create(nil, Files, Background, UserWishForContextMenu);
ShellContextMenu.OnClose := CloseEvent;
// Show context menu
MacosServiceMenuHelper.PopUp( ShellContextMenu, rsMacOSMenuServices, filepath );
try
// Create new context menu
ShellContextMenu:= TShellContextMenu.Create(nil, Files, Background, UserWishForContextMenu);
ShellContextMenu.OnClose := CloseEvent;
// Show context menu
MacosServiceMenuHelper.PopUp( ShellContextMenu, rsMacOSMenuServices, filepath );
finally
// Free created menu
FreeAndNil(ShellContextMenu);
end;
end;
{$ELSE}
begin