cocoa: don't pass Draw event outside the main thread

git-svn-id: trunk@38954 -
This commit is contained in:
paul 2012-10-03 01:38:03 +00:00
parent 7152323181
commit 8929340e01
2 changed files with 8 additions and 2 deletions

View File

@ -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;

View File

@ -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;