From 0a82041306e0837bb6b975991eebeb1a20771ca5 Mon Sep 17 00:00:00 2001 From: freq Date: Fri, 7 Mar 2014 19:59:05 +0000 Subject: [PATCH] Cocoa: Remove unused NSApp delegate that created memory leaks and crashes with libraries. git-svn-id: trunk@44371 - --- lcl/interfaces/cocoa/cocoaint.pas | 7 +------ lcl/interfaces/cocoa/cocoaobject.inc | 13 +------------ lcl/interfaces/cocoa/cocoawscommon.pas | 3 +++ 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoaint.pas b/lcl/interfaces/cocoa/cocoaint.pas index 2b9c363051..bae4802fd2 100644 --- a/lcl/interfaces/cocoa/cocoaint.pas +++ b/lcl/interfaces/cocoa/cocoaint.pas @@ -49,11 +49,6 @@ type class function initWithFunc(afunc: TWSTimerProc): TCocoaTimerObject; message 'initWithFunc:'; end; - { TCocoaAppDelegate } - - TCocoaAppDelegate = objcclass(NSObject, NSApplicationDelegateProtocol) - function applicationShouldTerminate(sender: NSApplication): NSApplicationTerminateReply; message 'applicationShouldTerminate:'; - end; { TCocoaWidgetSet } @@ -63,7 +58,7 @@ type FNSApp: NSApplication; FCurrentCursor: HCursor; FCaptureControl: HWND; - delegate: TCocoaAppDelegate; + protected FStockNullBrush: HBRUSH; FStockBlackBrush: HBRUSH; diff --git a/lcl/interfaces/cocoa/cocoaobject.inc b/lcl/interfaces/cocoa/cocoaobject.inc index 6b046ccb00..c46cf6ba7e 100644 --- a/lcl/interfaces/cocoa/cocoaobject.inc +++ b/lcl/interfaces/cocoa/cocoaobject.inc @@ -25,19 +25,15 @@ Initialize Carbon Widget Set ------------------------------------------------------------------------------} procedure TCocoaWidgetSet.AppInit(var ScreenInfo: TScreenInfo); -var pool: NSAutoreleasePool; begin {$IFDEF VerboseObject} DebugLn('TCocoaWidgetSet.AppInit'); {$ENDIF} - delegate := TCocoaAppDelegate.alloc.init; { Creates the application NSApp object } FNsApp := NSApplication.sharedApplication; - pool := NSAutoreleasePool.alloc.init; - FNSApp.setDelegate(delegate); - pool.release; + end; {------------------------------------------------------------------------------ @@ -474,13 +470,6 @@ begin end; -{ TCocoaAppDelegate } - -function TCocoaAppDelegate.applicationShouldTerminate(sender: NSApplication): NSApplicationTerminateReply; -begin - Result := NSTerminateNow; -end; - { TCocoaTimerObject } procedure TCocoaTimerObject.timerEvent; diff --git a/lcl/interfaces/cocoa/cocoawscommon.pas b/lcl/interfaces/cocoa/cocoawscommon.pas index 9f7dd5b2b6..036f25db3b 100644 --- a/lcl/interfaces/cocoa/cocoawscommon.pas +++ b/lcl/interfaces/cocoa/cocoawscommon.pas @@ -1090,15 +1090,18 @@ var obj: NSObject; Callback: ICommonCallback; CallbackObject: TObject; + pool: NSAutoreleasePool; begin if not AWinControl.HandleAllocated then Exit; + pool := NSAutoreleasePool.alloc.init; obj := NSObject(AWinControl.Handle); if obj.isKindOfClass_(NSView) then NSView(obj).removeFromSuperview else if obj.isKindOfClass_(NSWindow) then NSWindow(obj).close; + pool.release; // destroy the callback Callback := obj.lclGetCallback; if Assigned(Callback) then