Browse Source

* Check allowed options when setting options not in constructor

git-svn-id: trunk@33220 -
michael 9 years ago
parent
commit
e160b09468
1 changed files with 5 additions and 0 deletions
  1. 5 0
      packages/fcl-base/src/inifiles.pp

+ 5 - 0
packages/fcl-base/src/inifiles.pp

@@ -543,8 +543,13 @@ begin
 end;
 end;
 
 
 procedure TCustomIniFile.SetOptions(AValue: TIniFileOptions);
 procedure TCustomIniFile.SetOptions(AValue: TIniFileOptions);
+
+Const
+  CreateOnlyOptions = [ifoStripComments,ifoStripInvalid];
 begin
 begin
   if FOptions=AValue then Exit;
   if FOptions=AValue then Exit;
+  if (Foptions*CreateOnlyOptions)<>(AValue*CreateOnlyOptions) then
+    Raise Exception.Create('Can only change StripComments or StripInvalid in constructor');
   FOptions:=AValue;
   FOptions:=AValue;
 end;
 end;