LazMapViewer: Fix TMapViewer.CyclicPointsOf crashing if called outside Paint method.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9506 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
17132ec44a
commit
03cf0e9c90
@ -27,8 +27,9 @@ unit mvMapViewer;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Controls, GraphType, Graphics, FPImage, IntfGraphics,
|
||||
Forms, ImgList, LCLVersion, fgl,
|
||||
Classes, SysUtils, Types, fgl, FPImage,
|
||||
Controls, GraphType, Graphics, IntfGraphics,
|
||||
Forms, ImgList, LCLVersion,
|
||||
mvTypes, mvGeoMath, mvGPSObj, mvDragObj, mvCache, mvExtraData,
|
||||
mvEngine, mvMapProvider, mvDownloadEngine, mvDrawingEngine;
|
||||
|
||||
@ -436,6 +437,7 @@ type
|
||||
private
|
||||
FCacheLocation: TCacheLocation;
|
||||
FCachePath, FCacheFullPath: String;
|
||||
FCanvasSize: TSize; // Needed for calculation of cyclic points
|
||||
FCenter: TMapCenter;
|
||||
FDownloadEngine: TMvCustomDownloadEngine;
|
||||
FBuiltinDownloadEngine: TMvCustomDownloadEngine;
|
||||
@ -848,7 +850,7 @@ type
|
||||
implementation
|
||||
|
||||
uses
|
||||
FileUtil, LazLoggerBase, Types, Math,
|
||||
FileUtil, LazLoggerBase, Math,
|
||||
mvJobQueue,
|
||||
mvDLEFPC,
|
||||
{$IFDEF MSWINDOWS}
|
||||
@ -2579,6 +2581,8 @@ begin
|
||||
Engine.SetSize(ClientWidth, ClientHeight);
|
||||
Invalidate;
|
||||
end;
|
||||
if (FCanvasSize.CX = 0) and (FCanvasSize.CY = 0) then
|
||||
FCanvasSize := Size(ClientWidth + 100, ClientHeight); // will be updated correctly in Paint
|
||||
end;
|
||||
|
||||
procedure TMapView.Paint;
|
||||
@ -2608,14 +2612,14 @@ const
|
||||
W: Integer;
|
||||
begin
|
||||
Engine.Redraw;
|
||||
W := Canvas.Width;
|
||||
W := FCanvasSize.CX;
|
||||
if Cyclic then
|
||||
W := Min(1 shl Zoom * TileSize.CX, W);
|
||||
|
||||
if Assigned(FBeforeDrawObjectsEvent) then
|
||||
FBeforeDrawObjectsEvent(Self);
|
||||
|
||||
DrawObjects(Default(TTileId), 0, 0, W - 1, Canvas.Height);
|
||||
DrawObjects(Default(TTileId), 0, 0, W - 1, FCanvasSize.CY);
|
||||
|
||||
if Assigned(FAfterDrawObjectsEvent) then
|
||||
FAfterDrawObjectsEvent(Self);
|
||||
@ -2644,12 +2648,15 @@ const
|
||||
|
||||
begin
|
||||
inherited Paint;
|
||||
if IsActive
|
||||
then if Engine.InDrag
|
||||
then DragDraw
|
||||
else FullRedraw
|
||||
FCanvasSize := Size(Canvas.Width, Canvas.Height);
|
||||
if IsActive then
|
||||
begin
|
||||
if Engine.InDrag then
|
||||
DragDraw
|
||||
else
|
||||
InactiveDraw;
|
||||
FullRedraw;
|
||||
end else
|
||||
InactiveDraw;
|
||||
end;
|
||||
|
||||
procedure TMapView.OnGPSItemsModified(Sender: TObject; objs: TGPSObjList;
|
||||
@ -3272,7 +3279,7 @@ end;
|
||||
|
||||
function TMapView.CyclicPointsOf(APoint: TPoint): TPointArray;
|
||||
var
|
||||
I, R, L, WorldSize, CanvasWidth: LongInt;
|
||||
I, R, L, WorldSize: LongInt;
|
||||
begin
|
||||
Result := Default(TPointArray);
|
||||
if not Cyclic then
|
||||
@ -3283,13 +3290,12 @@ begin
|
||||
else
|
||||
begin
|
||||
WorldSize := mvGeoMath.ZoomFactor(Zoom) * TileSize.CX;
|
||||
CanvasWidth := Canvas.Width;
|
||||
SetLength(Result, 1{APoint} + (1{Round} + CanvasWidth div WorldSize));
|
||||
SetLength(Result, 1{APoint} + (1{Round} + FCanvasSize.CX div WorldSize));
|
||||
Result[0] := APoint;
|
||||
I := 1; R := APoint.X + WorldSize; L := APoint.X - WorldSize;
|
||||
while (R < CanvasWidth) or (L >= 0) do
|
||||
while (R < FCanvasSize.CX) or (L >= 0) do
|
||||
begin
|
||||
if R < CanvasWidth then
|
||||
if R < FCanvasSize.CX then
|
||||
begin
|
||||
Result[I].Y := APoint.Y;
|
||||
Result[I].X := R;
|
||||
|
Loading…
Reference in New Issue
Block a user