franzini81 / gmlibrary

Automatically exported from code.google.com/p/gmlibrary
0 stars 0 forks source link

Invalid pointer where destroy form with Gmlib and Polilyne #48

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Valirize Poliline 
2.Destroy form 
3.

What is the expected output? destructor TLinePoint.Destroy; Invalid Pointer 
when 
Destroy GmLib

What version of the product are you using? On what operating system? IE
Version?  1.3.0 > 1.5.0

Original issue reported on code.google.com by syri...@gmail.com on 4 Nov 2014 at 4:11

GoogleCodeExporter commented 9 years ago
Can you send me more info about this problem?? I understand you

Regards

Original comment by cadet...@gmail.com on 15 Nov 2014 at 12:26

GoogleCodeExporter commented 9 years ago
hi ,

i use this function for add poit to maps like Gps navigato with last n°
point

procedure TFrameGoogle.ShowPosToGoogle(Lat,Lng,Direction:array of Extended);
var png : TPNGObject;
    I   : Integer;
    Dir : Extended;
begin
  if (csDestroying in ComponentState) then
    Exit;
  if not Assigned(WebBrowser1) then
    Exit;
  TWinControl(WebBrowser1).Parent := cxGroupBox2;
  Windows.SetParent(WebBrowser1.Handle, cxGroupBox2.Handle);

  if FFlagMapGoogle_Attiva then
  begin
    if not  Gmmap1.Active  then Exit;

    try

      {marker macchina}
      if Not Assigned(FMarker) then
      begin
        FMarker := GMMarker1.Add(Lat[0],Lng[0]);
        GMMap1.RequiredProp.Zoom := 17;
      end;

      {Coda}
      if Not Assigned(Fpoli) then
      begin
        Fpoli := GMPolyline1.Add;
      end;

      {Pulizia della coda}
      Fpoli.LinePoints.Clear;
      for I := 0 to Length(Lat) -1 do
      begin
        Fpoli.AddLinePoint(Lat[I], Lng[I]);
      end;

      Fpoli.StrokeColor              := clRed;
      Fpoli.StrokeWeight             := 2;
      Fpoli.StrokeOpacity            := 1;
      Fpoli.Geodesic                 := True;
      Fpoli.Clickable                := False;
      Fpoli.Editable                 := False;
      Fpoli.Icon.Icon.Path           := spFORWARD_CLOSED_ARROW;
      Fpoli.Icon.Icon.FillColor      := clRed;
      Fpoli.Icon.Icon.FillOpacity    := 1;
      Fpoli.Icon.Icon.StrokeColor    := clRed;
      Fpoli.Icon.OffSet.Measure      := mPixels;
      Fpoli.Icon.OffSet.Value        := 0;
      Fpoli.Icon.DistRepeat.Value    := 25;;
      Fpoli.Icon.DistRepeat.Measure  := mPercentage;
      Fpoli.Icon.Icon.StrokeOpacity  := 1;
      Fpoli.Icon.Icon.StrokeWeight   := 2;
      Fpoli.Visible                  := True;

      {Rotazione immagine}
      Dir := Direction[ Length(Direction) -1 ];
      Try
        png := TPNGObject.Create;
        if FileExists(FApplicationInfo.Path.ResourceGoogleGPS+'M0.png') then
        begin

png.LoadFromFile(FApplicationInfo.Path.ResourceGoogleGPS+'M0.png');
          SmoothRotate(png,Dir);
          ForceDirectories(FApplicationInfo.Path.Temp+'GPSIcon\');

png.SaveToFile(FApplicationInfo.Path.Temp+'GPSIcon\M0'+FloatToStr(Dir)+'.png');
        end;
      Finally
        png.free;
      End;
      FMarker.Visible   := False;
      FMarker.Position  := Fpoli.LinePoints[Fpoli.LinePoints.Count
-1].GetLatLng;
      if
FileExists(FApplicationInfo.Path.Temp+'GPSIcon\M0'+FloatToStr(Dir)+'.png')
then
        FMarker.Icon      :=
FApplicationInfo.Path.Temp+'GPSIcon\M0'+FloatToStr(Dir)+'.png';
      FMarker.Optimized := False;
      FMarker.Visible   := True;

      GMMap1.PanTo(FMarker.Position);

    except on E : exception do
    begin
      {$REGION 'Log'}
      {TSI:IGNORE ON}

LogModule.ScriviLog(Format('[%p]%s.ShowPosToGoogle',[pointer(Self),Self.Classnam
e]),
        Format('Exception %s',[e.message]),tpliv1);
      {TSI:IGNORE OFF}
      {$ENDREGION}
    end;
    end;
  end;
end;

when Call this form , from event destroy of Owner with this code

procedure TFrameGoogle.FormCloseQuery(Sender: TObject; var CanClose:
Boolean);
var  I : Integer;
begin
  if Not FFlagMapGoogle_Attiva then
  begin
    CanClose := True;
    Exit;
  end;
  Try
    FFlagMapGoogle_Attiva := false;
    {$REGION 'Log'}
    {TSI:IGNORE ON}

LogModule.ScriviLog(Format('[%p]%s.FormDestroy',[pointer(Self),Self.Classname]),
      Format('Deinizializzo GmLib',[]),tpliv4);
    {TSI:IGNORE OFF}
    {$ENDREGION}

    if (FMarker <> nil) then
    begin
      FMarker.Free;
    end;
    {$REGION 'Log'}
    {TSI:IGNORE ON}

LogModule.ScriviLog(Format('[%p]%s.FormDestroy',[pointer(Self),Self.Classname]),
      Format('GMMarker1.Clear',[]),tpliv4);
    {TSI:IGNORE OFF}
    {$ENDREGION}

    {$REGION 'Log'}
    {TSI:IGNORE ON}

LogModule.ScriviLog(Format('[%p]%s.FormDestroy',[pointer(Self),Self.Classname]),
      Format('GMMap1.Active = False',[]),tpliv4);
    {TSI:IGNORE OFF}
    {$ENDREGION}
    Try
      GMMarker1.Clear;
      if Assigned(Fpoli) then
        Fpoli.Free;
    except

    End;
    GMMap1.WebBrowser := nil;
    GMMap1.Active := false;
  except  on E: Exception do
    begin
      {$REGION 'Log'}
      {TSI:IGNORE ON}

LogModule.ScriviLog(Format('[%p]%s.FormDestroy',[pointer(Self),Self.Classname]),
        Format('%s',[e.Message]),tpliv1);
      {TSI:IGNORE OFF}
      {$ENDREGION}
    end;
  End;
  CanClose := True;
end;

i recive the exception when destroy Fpoli.

thanks for your job

by

2014-11-15 13:26 GMT+01:00 <gmlibrary@googlecode.com>:

Original comment by syri...@gmail.com on 28 Nov 2014 at 5:00

GoogleCodeExporter commented 9 years ago
I understand that FPoly is destroyed when GMPolyline1 is destroyed. What of the 
two objects is destroyed first?

Original comment by cadet...@gmail.com on 29 Jul 2015 at 9:56