mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 01:41:22 +02:00
* Fixed nil pointer dereference when jumping to source when all tabs are closed (reported by Martin Friebe)
* Fixed possible nil pointer dereference when callstack returns a nil entry (reported by Martin Friebe) * Simplified copying callstack to clipboard git-svn-id: trunk@14213 -
This commit is contained in:
parent
e91dacd68b
commit
6379cc6061
@ -191,13 +191,23 @@ begin
|
||||
begin
|
||||
Item := lvCallStack.Items[n];
|
||||
Entry := CallStack.Entries[First + n];
|
||||
if Entry.Current
|
||||
then Item.Caption := '>'
|
||||
else Item.Caption := ' ';
|
||||
Item.SubItems[0] := IntToStr(Entry.Index);
|
||||
Item.SubItems[1] := Entry.Source;
|
||||
Item.SubItems[2] := IntToStr(Entry.Line);
|
||||
Item.SubItems[3] := GetFunction(Entry);
|
||||
if Entry = nil
|
||||
then begin
|
||||
Item.Caption := '';
|
||||
Item.SubItems[0] := '????';
|
||||
Item.SubItems[1] := '';
|
||||
Item.SubItems[2] := '';
|
||||
Item.SubItems[3] := '';
|
||||
end
|
||||
else begin
|
||||
if Entry.Current
|
||||
then Item.Caption := '>'
|
||||
else Item.Caption := ' ';
|
||||
Item.SubItems[0] := IntToStr(Entry.Index);
|
||||
Item.SubItems[1] := Entry.Source;
|
||||
Item.SubItems[2] := IntToStr(Entry.Line);
|
||||
Item.SubItems[3] := GetFunction(Entry);
|
||||
end;
|
||||
end;
|
||||
|
||||
finally
|
||||
@ -257,24 +267,22 @@ procedure TCallStackDlg.CopyToClipBoard;
|
||||
var
|
||||
n: integer;
|
||||
Entry: TCallStackEntry;
|
||||
EntryList: TStringList;
|
||||
S: String;
|
||||
begin
|
||||
Clipboard.Clear;
|
||||
|
||||
if (CallStack=nil) or (CallStack.Count=0) then exit;
|
||||
|
||||
EntryList:=TStringList.Create;
|
||||
try
|
||||
EntryList.Capacity:=CallStack.Count;
|
||||
for n:= 0 to CallStack.Count-1 do begin
|
||||
Entry:=CallStack.Entries[n];
|
||||
EntryList.Add(format('#%d %s at %s:%d',
|
||||
[n, GetFunction(Entry), Entry.Source, Entry.Line]));
|
||||
end;
|
||||
ClipBoard.AsText := EntryList.Text;
|
||||
finally
|
||||
EntryList.Free;
|
||||
S := '';
|
||||
for n:= 0 to CallStack.Count-1 do
|
||||
begin
|
||||
Entry:=CallStack.Entries[n];
|
||||
if Entry <> nil
|
||||
then S := S + format('#%d %s at %s:%d', [n, GetFunction(Entry), Entry.Source, Entry.Line])
|
||||
else S := S + format('#%d ????', [n]);
|
||||
S := S + LineEnding;
|
||||
end;
|
||||
ClipBoard.AsText := S;
|
||||
end;
|
||||
|
||||
procedure TCallStackDlg.lvCallStackDBLCLICK(Sender: TObject);
|
||||
|
11
ide/main.pp
11
ide/main.pp
@ -11238,13 +11238,17 @@ begin
|
||||
|
||||
if (ActiveSrcEdit=nil) or (ActiveUnitInfo=nil) then
|
||||
GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);
|
||||
if AddJumpPoint then begin
|
||||
|
||||
if AddJumpPoint and (ActiveUnitInfo <> nil) and (ActiveSrcEdit <> nil)
|
||||
then begin
|
||||
if (NewSource<>ActiveUnitInfo.Source)
|
||||
or (ActiveSrcEdit.EditorComponent.CaretX<>NewX)
|
||||
or (ActiveSrcEdit.EditorComponent.CaretY<>NewY) then
|
||||
SourceNotebook.AddJumpPointClicked(Self);
|
||||
end;
|
||||
if NewSource<>ActiveUnitInfo.Source then begin
|
||||
|
||||
if (ActiveUnitInfo = nil) or (NewSource<>ActiveUnitInfo.Source)
|
||||
then begin
|
||||
// jump to other file -> open it
|
||||
Result:=DoOpenEditorFile(NewSource.Filename,-1,[ofOnlyIfExists,ofRegularFile]);
|
||||
if Result<>mrOk then begin
|
||||
@ -11253,7 +11257,8 @@ begin
|
||||
end;
|
||||
GetUnitWithPageIndex(SourceNoteBook.NoteBook.PageIndex,NewSrcEdit,
|
||||
NewUnitInfo);
|
||||
end else begin
|
||||
end
|
||||
else begin
|
||||
NewSrcEdit:=ActiveSrcEdit;
|
||||
end;
|
||||
if NewX<1 then NewX:=1;
|
||||
|
Loading…
Reference in New Issue
Block a user