TRegIniFile.OpenKey does not update FCurrenPath correctly
Original Reporter info from Mantis: Bart @flyingsheep
-
Reporter name: Bart Broersma
Original Reporter info from Mantis: Bart @flyingsheep
- Reporter name: Bart Broersma
Description:
Consider this code snippet (copied from #35022 (closed))
function CreateTestEntry: Boolean;
const
BoolStr: array[Boolean] of String = ('False','True');
OKStr: array[Boolean] of String = ('FAIL','OK');
var
RegIni: TRegIniFile;
B: Boolean;
function TryOpenKey(Key: String; CanCreate: Boolean): Boolean;
begin
Result := RegIni.OpenKey(Key, CanCreate);
writeln(format('OpenKey(''%s'',%s): %s',[Key,BoolStr[CanCreate],OkStr[Result]]));
end;
begin
Result := False;
RegIni := TRegIniFile.Create('\Software');
try
writeln('CurrentPath=',RegIni.CurrentPath);
B := RegIni.CreateKey('FPCTEST');
writeln('CreateKey=',B);
if not B then Exit;
if not TryOpenKey('FPCTEST',False) then Exit;
writeln('CurrentPath=',RegIni.CurrentPath);
if not TryOpenKey('RegIni',True) then Exit;
writeln('CurrentPath=',RegIni.CurrentPath);
Result := True;
finally
RegIni.Free;
end;
end;
var
B: Boolean;
begin
B := CreateTestEntry;
writeln('CreateTestEntry=',B);
end.
Steps to reproduce:
Build and run the program on Windows.
Expected output (tested with Delphi 7):
CurrentPath=Software
CreateKey=TRUE
OpenKey('FPCTEST',False): OK
CurrentPath=Software\FPCTEST
OpenKey('RegIni',True): OK
CurrentPath=Software\FPCTEST\RegIni
Output of FPC trunk:
CurrentPath=Software
CreateKey=TRUE
OpenKey('FPCTEST',False): OK
CurrentPath=SoftwareFPCTEST <<--
OpenKey('RegIni',True): OK
CurrentPath=SoftwareFPCTESTRegIni <<--
Mantis conversion info:
- Mantis ID: 35023
- OS: Linux Mint
- OS Build: 18.0
- Build: r40745
- Platform: x86_64
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 44478 (#a24a4b97)
- Target version: 3.2.0