codetools: TSourceLog.LoadFromStream: check if source has changed

git-svn-id: trunk@35935 -
This commit is contained in:
mattias 2012-03-13 20:12:36 +00:00
parent 1de0002886
commit 6088a1a052

View File

@ -170,8 +170,8 @@ type
function OldIsEqual(sl: TStrings): boolean; function OldIsEqual(sl: TStrings): boolean;
procedure Assign(sl: TStrings); procedure Assign(sl: TStrings);
procedure AssignTo(sl: TStrings; UseAddStrings: Boolean); procedure AssignTo(sl: TStrings; UseAddStrings: Boolean);
procedure LoadFromStream(s: TStream); procedure LoadFromStream(aStream: TStream);
procedure SaveToStream(s: TStream); procedure SaveToStream(aStream: TStream);
property ReadOnly: boolean read FReadOnly write SetReadOnly; property ReadOnly: boolean read FReadOnly write SetReadOnly;
property DiskEncoding: string read FDiskEncoding write FDiskEncoding; property DiskEncoding: string read FDiskEncoding write FDiskEncoding;
property MemEncoding: string read FMemEncoding write FMemEncoding; property MemEncoding: string read FMemEncoding write FMemEncoding;
@ -1056,24 +1056,30 @@ begin
end; end;
end; end;
procedure TSourceLog.LoadFromStream(s: TStream); procedure TSourceLog.LoadFromStream(aStream: TStream);
var
NewSrcLen: integer;
NewSource: String;
begin begin
IncreaseHookLock; IncreaseHookLock;
Clear; try
if s=nil then exit; if aStream=nil then exit;
s.Position:=0; aStream.Position:=0;
fSrcLen:=s.Size-s.Position; NewSrcLen:=aStream.Size-aStream.Position;
if fSrcLen>0 then begin NewSource:='';
SetLength(fSource,fSrcLen); if NewSrcLen>0 then begin
s.Read(fSource[1],fSrcLen); SetLength(NewSource,NewSrcLen);
aStream.Read(NewSource[1],NewSrcLen);
end;
Source:=NewSource;
finally
DecreaseHookLock;
end; end;
fLineCount:=-1;
DecreaseHookLock;
end; end;
procedure TSourceLog.SaveToStream(s: TStream); procedure TSourceLog.SaveToStream(aStream: TStream);
begin begin
if fSource<>'' then s.Write(fSource[1],fSrcLen); if fSource<>'' then aStream.Write(fSource[1],fSrcLen);
end; end;
procedure TSourceLog.SetReadOnly(const Value: boolean); procedure TSourceLog.SetReadOnly(const Value: boolean);