mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-01 17:52:47 +02:00
cocoa: don't pass Draw event outside the main thread
git-svn-id: trunk@38954 -
This commit is contained in:
parent
7152323181
commit
8929340e01
@ -412,6 +412,7 @@ type
|
||||
end;
|
||||
|
||||
procedure SetViewDefaults(AView: NSView);
|
||||
function CheckMainThread: Boolean;
|
||||
|
||||
implementation
|
||||
|
||||
@ -421,6 +422,11 @@ begin
|
||||
AView.setAutoresizingMask(NSViewMinYMargin or NSViewMaxXMargin);
|
||||
end;
|
||||
|
||||
function CheckMainThread: Boolean;
|
||||
begin
|
||||
Result := NSThread.currentThread.isMainThread;
|
||||
end;
|
||||
|
||||
{ TCocoaPanel }
|
||||
|
||||
function TCocoaPanel.windowShouldClose(sender: id): LongBool;
|
||||
@ -893,7 +899,8 @@ end;
|
||||
procedure TCocoaCustomControl.drawRect(dirtyRect: NSRect);
|
||||
begin
|
||||
inherited drawRect(dirtyRect);
|
||||
callback.Draw(NSGraphicsContext.currentContext, bounds, dirtyRect);
|
||||
if CheckMainThread then
|
||||
callback.Draw(NSGraphicsContext.currentContext, bounds, dirtyRect);
|
||||
end;
|
||||
|
||||
function TCocoaCustomControl.lclGetCallback: ICommonCallback;
|
||||
|
@ -777,7 +777,6 @@ end;
|
||||
|
||||
function TLCLCommonCallback.DeliverMessage(var Msg): LRESULT;
|
||||
begin
|
||||
// WriteLn('Delivering message to target: ', PtrInt(Target), ' ', Target.ClassName);
|
||||
Result := LCLMessageGlue.DeliverMessage(Target, Msg);
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user