Yuri,
I'm having strange problems with freeing objects, I get AV's.
Here's some code ($mode delphi):
var List: TStrList;
begin
List := RegEnum(OptionsKeyBase + '\Profiles')^;
// RegEnum returns PStrList
try
if List.Count > 0 then
for i := 0 to List.Count - 1 do begin
S := List.Items[i];
while (Pos('\', S) > 0) do
S := Copy(S, Pos('\', S) + 1, Length(S));
if S <> DefaultProfileName then begin
with AddProfile do begin
Name := S;
LoadFromRegistry;
end;
end else begin
Profile[DefaultProfile].LoadFromRegistry;
end;
end;
finally
List.Free; // <---- AV HERE
end;
end;
Ofcourse I have also tried with removing the code between try/finally. Seems it happens as soon as List has a string inside. Stack trace:
An unhandled exception occurred at $03F700BC :
EAccessViolation : Access violation
$03F700BC
$00011B80 fpc_help_destructor, line 423 of C:/lazarus/source/fpcbuild/2.1/fpcsrc/rtl/inc/generic.inc
$0001F574 TOBJ__REFDEC, line 14517 of E:/SoftDev/kol-ce-2.80/kol/KOL.PAS
$00029DB8 TWMWROPTIONS__LOADFROMREGISTRY, line 539 of cwmwroptions.pas
$00027590 TFORM1__KOLFORM1FORMCREATE, line 99 of unit1.pas
$0002743C NEWFORM1, line 63 of unit1_1.inc
$0001165C main, line 10 of skeleton.lpr
This is not the only place it happens either, I get it when freeing other lists as well (TList). Cannot determine what causes it, but I can't get the error to disappear either. It works if I comment out the "List.Free", but then I won't be freeing memory.
Any help, advice, etc ?