cocoa: doing the proper time release of the main autorelease pool.

git-svn-id: trunk@61160 -
This commit is contained in:
dmitry 2019-05-05 18:53:05 +00:00
parent a17ed6695c
commit 14eaeb1c76
2 changed files with 17 additions and 7 deletions
lcl/interfaces/cocoa

View File

@ -532,6 +532,16 @@ begin
Result:=inherited runModalForWindow(theWindow);
end;
procedure InternalFinal;
begin
if Assigned(MainPool) then
begin
MainPool.release;
MainPool := nil;
end;
end;
// the implementation of the utility methods
{$I cocoaobject.inc}
// the implementation of the winapi compatibility methods
@ -546,12 +556,6 @@ begin
MainPool := NSAutoreleasePool.alloc.init;
end;
procedure InternalFinal;
begin
if Assigned(MainPool) then MainPool.release;
end;
procedure TCocoaWidgetSet.DoSetMainMenu(AMenu: NSMenu; ALCLMenu: TMenu);
var
i: Integer;
@ -668,7 +672,6 @@ end;
initialization
// {$I Cocoaimages.lrs}
InternalInit;
finalization

View File

@ -222,6 +222,13 @@ begin
// NSApp.terminate(nil); // causes app to quit immediately, which is undesirable
// Must release the Main autorelease pool here.
// Some objects still in the pool my depend on releasing Widgetset objects
// (i.e. images). If autorelease pool is released After the widgetset object
// then it finalization of WS dependent objects would fail (suppressed AVs)
// and would cause leaks. (see #35400)
InternalFinal;
CocoaWidgetSet := nil;
end;