Landiin
2007-10-04 23:42:51 UTC
Here is the scenario,
In my component I have a procedure that for loops through a string
list checking for strings. The stringlist is a global and my issue
occores if the component is destroy while in that procedure. What is
happening is the global stringlist is getting freed in the destroy
procedure and when the execution flow exits the destroy procedure at
some point it returns to the procedure that has the for loop in it.
and when it check the string list I get an AV of course because it has
been freed.
Procedure CheckList
var
i: integer;
Begin
Status := 'Checking list';
if bStop then
exit;
for I := 0 to List.Count -1 do <-- Get an AV here destroy is called
after execution is past the bStop check
begin
if List.Strings[I] := 'what erver' then <-- Get an AV here if destroy
is called while in the for loop
begin
do somthing
end;
End;
Deconstructor Destroy
begin
bStop := True;
if assigned(List)
List.free;
inherited;
end;
I know you wouldn't think it would get count at the for loop but it
does. How do I handle this to keep if from creating AVs?
Thanks for any help.
In my component I have a procedure that for loops through a string
list checking for strings. The stringlist is a global and my issue
occores if the component is destroy while in that procedure. What is
happening is the global stringlist is getting freed in the destroy
procedure and when the execution flow exits the destroy procedure at
some point it returns to the procedure that has the for loop in it.
and when it check the string list I get an AV of course because it has
been freed.
Procedure CheckList
var
i: integer;
Begin
Status := 'Checking list';
if bStop then
exit;
for I := 0 to List.Count -1 do <-- Get an AV here destroy is called
after execution is past the bStop check
begin
if List.Strings[I] := 'what erver' then <-- Get an AV here if destroy
is called while in the for loop
begin
do somthing
end;
End;
Deconstructor Destroy
begin
bStop := True;
if assigned(List)
List.free;
inherited;
end;
I know you wouldn't think it would get count at the for loop but it
does. How do I handle this to keep if from creating AVs?
Thanks for any help.