mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 16:29:38 +02:00
cocoa: changing the way application object goes into a loop and being initialized. fixes KVO exception for macOS10.15. Based on patch by David Jenkins. (original patch suggests removal of the existing code, the change introduces COCOALOOPOVERRIDE switch). #35702
git-svn-id: trunk@61354 -
This commit is contained in:
parent
deb2cde704
commit
7f6412df7e
@ -14,3 +14,10 @@
|
|||||||
{$define BOOLFIX}
|
{$define BOOLFIX}
|
||||||
|
|
||||||
|
|
||||||
|
// Originally LCL-Cocoa would override "run" method and have direct control
|
||||||
|
// over the event loop. However that presumed to cause issues in macOS 10.15
|
||||||
|
// The code was changed not to override "run" loop, but instead override
|
||||||
|
// the first request to process an event, and run LCL loop from there.
|
||||||
|
// Such approach is some what an ugly solution, yet it's reliable, in a sense
|
||||||
|
// that Cocoa performs ALL of this methods.
|
||||||
|
{.$define COCOALOOPOVERRIDE}
|
||||||
|
@ -70,8 +70,10 @@ type
|
|||||||
modals : NSMutableDictionary;
|
modals : NSMutableDictionary;
|
||||||
|
|
||||||
procedure dealloc; override;
|
procedure dealloc; override;
|
||||||
|
{$ifdef COCOALOOPOVERRIDE}
|
||||||
function isRunning: LCLObjCBoolean; override;
|
function isRunning: LCLObjCBoolean; override;
|
||||||
procedure run; override;
|
procedure run; override;
|
||||||
|
{$endif}
|
||||||
procedure sendEvent(theEvent: NSEvent); override;
|
procedure sendEvent(theEvent: NSEvent); override;
|
||||||
function nextEventMatchingMask_untilDate_inMode_dequeue(mask: NSUInteger; expiration: NSDate; mode: NSString; deqFlag: LCLObjCBoolean): NSEvent; override;
|
function nextEventMatchingMask_untilDate_inMode_dequeue(mask: NSUInteger; expiration: NSDate; mode: NSString; deqFlag: LCLObjCBoolean): NSEvent; override;
|
||||||
|
|
||||||
@ -397,6 +399,7 @@ begin
|
|||||||
inherited dealloc;
|
inherited dealloc;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$ifdef COCOALOOPOVERRIDE}
|
||||||
function TCocoaApplication.isRunning: LCLObjCBoolean;
|
function TCocoaApplication.isRunning: LCLObjCBoolean;
|
||||||
begin
|
begin
|
||||||
Result:=isrun;
|
Result:=isrun;
|
||||||
@ -407,6 +410,7 @@ begin
|
|||||||
isrun:=true;
|
isrun:=true;
|
||||||
aloop();
|
aloop();
|
||||||
end;
|
end;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
procedure ForwardMouseMove(app: NSApplication; theEvent: NSEvent);
|
procedure ForwardMouseMove(app: NSApplication; theEvent: NSEvent);
|
||||||
var
|
var
|
||||||
@ -503,6 +507,16 @@ function TCocoaApplication.nextEventMatchingMask_untilDate_inMode_dequeue(
|
|||||||
var
|
var
|
||||||
cb : ICommonCallback;
|
cb : ICommonCallback;
|
||||||
begin
|
begin
|
||||||
|
{$ifndef COCOALOOPOVERRIDE}
|
||||||
|
if not isrun then begin
|
||||||
|
isrun := True;
|
||||||
|
Result := nil;
|
||||||
|
aloop();
|
||||||
|
terminate(nil);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
{$ifdef BOOLFIX}
|
{$ifdef BOOLFIX}
|
||||||
Result:=inherited nextEventMatchingMask_untilDate_inMode_dequeue_(
|
Result:=inherited nextEventMatchingMask_untilDate_inMode_dequeue_(
|
||||||
mask,
|
mask,
|
||||||
|
@ -67,7 +67,9 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TCocoaWidgetSet.AppRun(const ALoop: TApplicationMainLoop);
|
procedure TCocoaWidgetSet.AppRun(const ALoop: TApplicationMainLoop);
|
||||||
begin
|
begin
|
||||||
|
{$ifndef COCOALOOPOVERRIDE}
|
||||||
NSApp.finishLaunching;
|
NSApp.finishLaunching;
|
||||||
|
{$endif}
|
||||||
if Assigned(ALoop) then
|
if Assigned(ALoop) then
|
||||||
begin
|
begin
|
||||||
TCocoaApplication(NSApp).aloop:=ALoop;
|
TCocoaApplication(NSApp).aloop:=ALoop;
|
||||||
|
Loading…
Reference in New Issue
Block a user