mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-05 23:58:06 +02:00
cocoa: Fixes crash due to ReleaseDC freeing wrongly control DCs
git-svn-id: trunk@49602 -
This commit is contained in:
parent
15a40e33f7
commit
77e8b6e2d1
@ -386,6 +386,7 @@ type
|
||||
procedure ClearClipping;
|
||||
public
|
||||
ctx: NSGraphicsContext;
|
||||
isControlDC: Boolean; // control DCs should never be freed by ReleaseDC as the control will free it by itself
|
||||
constructor Create(AGraphicsContext: NSGraphicsContext); virtual;
|
||||
destructor Destroy; override;
|
||||
|
||||
@ -1942,11 +1943,13 @@ end;
|
||||
procedure TCocoaContext.ClearClipping;
|
||||
var
|
||||
Trans: CGAffineTransform;
|
||||
cgc: CGContextRef;
|
||||
begin
|
||||
if FClipped then
|
||||
begin
|
||||
Trans := CGContextGetCTM(CGContext);
|
||||
CGContextRestoreGState(CGContext());
|
||||
cgc := CGContext();
|
||||
Trans := CGContextGetCTM(cgc);
|
||||
CGContextRestoreGState(cgc);
|
||||
ApplyTransform(Trans);
|
||||
end;
|
||||
end;
|
||||
|
@ -1842,7 +1842,7 @@ var
|
||||
dc: TCocoaContext;
|
||||
gdi: TCocoaGDIObject;
|
||||
const
|
||||
SName = 'TCarbonWidgetSet.SelectObject';
|
||||
SName = 'TCocoaWidgetSet.SelectObject';
|
||||
begin
|
||||
{$IFDEF VerboseWinAPI}
|
||||
DebugLn(Format('TCocoaWidgetSet.SelectObject DC: %x GDIObj: %x', [ADC, GDIObj]));
|
||||
@ -2007,7 +2007,7 @@ begin
|
||||
ctx := CheckDC(DC);
|
||||
if not Assigned(ctx) then
|
||||
Exit;
|
||||
if (ctx <> DefaultContext) and (ctx<>ScreenContext) then
|
||||
if (ctx <> DefaultContext) and (ctx<>ScreenContext) and (not ctx.isControlDC) then
|
||||
ctx.Free;
|
||||
Result := 1;
|
||||
end;
|
||||
|
@ -1028,6 +1028,7 @@ begin
|
||||
if Assigned(FContext) then
|
||||
Exit;
|
||||
FContext := TCocoaContext.Create(ControlContext);
|
||||
FContext.isControlDC := True;
|
||||
try
|
||||
// debugln('Draw '+Target.name+' bounds='+Dbgs(NSRectToRect(bounds))+' dirty='+Dbgs(NSRectToRect(dirty)));
|
||||
if FContext.InitDraw(Round(bounds.size.width), Round(bounds.size.height)) then
|
||||
|
Loading…
Reference in New Issue
Block a user