Path from Alexander S. Klenin

* save cached changes when CacheUpdate is set to false
 * clear FDirty flag when the user calls UpdateFile directly

git-svn-id: trunk@12361 -
This commit is contained in:
joost 2008-12-13 15:05:50 +00:00
parent a0a1e6aae2
commit 1f1f38e5d3

View File

@ -167,6 +167,7 @@ type
procedure FillSectionList(AStrings: TStrings);
Procedure DeleteSection(ASection : TIniFileSection);
Procedure MaybeDeleteSection(ASection : TIniFileSection);
procedure SetCacheUpdates(const AValue: Boolean);
protected
procedure MaybeUpdateFile;
property Dirty : Boolean Read FDirty;
@ -184,7 +185,7 @@ type
procedure DeleteKey(const Section, Ident: String); override;
procedure UpdateFile; override;
property Stream: TStream read FStream;
property CacheUpdates : Boolean Read FCacheUpdates Write FCacheUpdates;
property CacheUpdates : Boolean read FCacheUpdates write SetCacheUpdates;
end;
TMemIniFile = class(TIniFile)
@ -757,6 +758,13 @@ begin
end;
end;
procedure TIniFile.SetCacheUpdates(const AValue: Boolean);
begin
if FCacheUpdates and not AValue and FDirty then
UpdateFile;
FCacheUpdates := AValue;
end;
procedure TIniFile.WriteString(const Section, Ident, Value: String);
var
oSection: TIniFileSection;
@ -940,6 +948,7 @@ begin
else if FStream <> nil then
slLines.SaveToStream(FStream);
FillSectionList(slLines);
FDirty := false;
finally
slLines.Free;
end;