Merged revision(s) 43719 #f2e9065f51 from trunk:

Gtk2: Fixed TGtk2WidgetSet.Polygon overwriting points array.Patch by Bart. issue #25507
........

git-svn-id: branches/fixes_1_2@43724 -
This commit is contained in:
maxim 2014-01-14 22:12:22 +00:00
parent 540515b860
commit 0ec3279913

View File

@ -6711,18 +6711,25 @@ function TGtk2WidgetSet.Polygon(DC: HDC; Points: PPoint; NumPts: Integer;
Winding: boolean): boolean;
var
DevCtx: TGtkDeviceContext absolute DC;
i: integer;
PointArray: PGDKPoint;
Tmp, RGN : hRGN;
ClipRect : TRect;
DCOrigin: TPoint;
OldNumPts: integer;
CurPoint: types.TPoint;
ThePoints: array of types.TPoint;
PThePoints: PPoint;
begin
if not IsValidDC(DC) then Exit(False);
if NumPts <= 0 then Exit(True);
//Create a copy of the points so we can freely alter them
SetLength(ThePoints, NumPts);
for i := 0 to NumPts - 1 do ThePoints[i] := Points[i];
PThePoints := @ThePoints[0];
DCOrigin := DevCtx.Offset;
OldNumPts := NumPts;
@ -6736,9 +6743,9 @@ begin
for i := 0 to NumPts - 1 do
begin
if DevCtx.HasTransf then
Points[I] := DevCtx.TransfPointIndirect(Points[I]);
PointArray[i].x := Points[i].x + DCOrigin.X;
PointArray[i].y := Points[i].y + DCOrigin.Y;
ThePoints[I] := DevCtx.TransfPointIndirect(ThePoints[I]);
PointArray[i].x := ThePoints[I].x + DCOrigin.X;
PointArray[i].y := ThePoints[I].y + DCOrigin.Y;
end;
if (Points[NumPts-1].X <> Points[0].X) or
@ -6762,7 +6769,7 @@ begin
Tmp := CreateEmptyRegion;
GetClipRGN(DC, Tmp);
// apply new clipping
RGN := CreatePolygonRgn(Points, OldNumPts, LCLType.Winding);
RGN := CreatePolygonRgn(PThePoints, OldNumPts, LCLType.Winding);
ExtSelectClipRGN(DC, RGN, RGN_AND);
DeleteObject(RGN);
GetClipBox(DC, @ClipRect);
@ -6791,10 +6798,11 @@ begin
{$IFDEF DebugGDKTraps}EndGDKErrorTrap;{$ENDIF}
if PointArray <> nil then FreeMem(PointArray);
SetLength(ThePoints,0);
Result := True;
end;
function TGtk2WidgetSet.Polyline(DC: HDC; Points: PPoint; NumPts: Integer): boolean;
var
DevCtx: TGtkDeviceContext absolute DC;