From: Erik B. <eb...@us...> - 2006-10-16 20:13:35
|
Update of /cvsroot/gexperts/gexperts/unstable/Src/Formatter In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv10438/Src/Formatter Modified Files: GX_CodeFormatterBreakpoints.pas Log Message: Ignore source breakpoint creation errors in D6/7 Other minor code tweaks Index: GX_CodeFormatterBreakpoints.pas =================================================================== RCS file: /cvsroot/gexperts/gexperts/unstable/Src/Formatter/GX_CodeFormatterBreakpoints.pas,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- GX_CodeFormatterBreakpoints.pas 19 Feb 2006 21:26:49 -0000 1.5 +++ GX_CodeFormatterBreakpoints.pas 16 Oct 2006 20:13:28 -0000 1.6 @@ -31,7 +31,6 @@ FExpression: string; FPassCount: Integer; public - constructor Create; // IOTABreakpoint (Delphi 2005) property StackFramesToLog: Integer read FStackFramesToLog write FStackFramesToLog; // IOTABreakpoint80 @@ -64,7 +63,7 @@ procedure Add(Item: TSourceBreakpoint); function Count: Integer; procedure Clear; - function Find(const AFilename: string; ALineNumber: integer; out Idx: integer): boolean; + function Find(const AFilename: string; ALineNumber: Integer; out Idx: Integer): Boolean; property Items[Idx: Integer]: TSourceBreakpoint read GetItems; default; end; @@ -82,18 +81,11 @@ implementation -{ TSourceBreakpoint } - -constructor TSourceBreakpoint.Create; -begin - inherited; -end; - { TBreakpoints } constructor TBreakpoints.Create; begin - inherited Create; + inherited; FList := TList.Create; end; @@ -103,37 +95,40 @@ begin for i := 0 to Count - 1 do TSourceBreakpoint(FList[i]).Free; - FList.Free; + FreeAndNil(FList); inherited; end; -function TBreakpoints.Find(const AFilename: string; ALineNumber: integer; - out Idx: integer): boolean; +function TBreakpoints.Find(const AFilename: string; ALineNumber: Integer; + out Idx: Integer): Boolean; var i: Integer; begin - for i := 0 to fList.Count - 1 do begin + for i := 0 to FList.Count - 1 do begin if SameText(Items[i].FileName, AFilename) and (Items[i].LineNumber = ALineNumber) then begin Idx := i; - Result := true; - exit; + Result := True; + Exit; end; end; - Result := false; + Result := False; end; function TBreakpoints.GetItems(Idx: Integer): TSourceBreakpoint; begin + Assert((Idx > -1) and (Idx < FList.Count)); Result := FList[Idx]; end; procedure TBreakpoints.Add(Item: TSourceBreakpoint); begin + Assert(Assigned(FList)); FList.Add(Item); end; function TBreakpoints.Count: Integer; begin + Assert(Assigned(FList)); Result := FList.Count; end; @@ -150,14 +145,16 @@ constructor TBreakpointHandler.Create; begin + // Must be first because the parent calls the SaveItems virtual FBreakpoints := TBreakpoints.Create; - inherited Create; + inherited; end; destructor TBreakpointHandler.Destroy; begin inherited; - FBreakpoints.Free; + // This must be last because of a call to RestoreItems in the parent + FreeAndNil(FBreakpoints); end; procedure TBreakpointHandler.RestoreItems; @@ -178,9 +175,13 @@ end; for i := 0 to FBreakpoints.Count - 1 do begin SrcBreakpoint := FBreakpoints[i]; - SrcBrkPtInt := DebuggerServices.NewSourceBreakpoint( - SrcBreakpoint.FileName, SrcBreakpoint.LineNumber, - DebuggerServices.CurrentProcess); + try + SrcBrkPtInt := DebuggerServices.NewSourceBreakpoint( + SrcBreakpoint.FileName, SrcBreakpoint.LineNumber, + DebuggerServices.CurrentProcess); + except + Break;// FIXME: Delphi 6/7 do not support recreation of source breakpoints at designtime (EListError: List index out of bounds (-1)) + end; {$IFDEF GX_VER170_up} SrcBrkPtInt.StackFramesToLog := SrcBreakpoint.StackFramesToLog; {$ENDIF} |