Skip to content

Commit

Permalink
Fix AV in IOC for Singleton non-interfaced class
Browse files Browse the repository at this point in the history
A non-interfaced class registered in the IOC as Singleton, was raising an AV when the container was freed
  • Loading branch information
jkour committed Mar 19, 2023
1 parent 767356c commit 2bb4861
Show file tree
Hide file tree
Showing 2 changed files with 419 additions and 234 deletions.
4 changes: 3 additions & 1 deletion Quick.IOC.pas
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@ destructor TIocRegistrator.Destroy;
if fDependencyOrder[i] <> nil then
begin
//free singleton instances not interfaced
if (fDependencyOrder[i] is TIocRegistrationInstance) and (TIocRegistrationInstance(fDependencyOrder[i]).IsSingleton) then TIocRegistrationInstance(regs[i]).Instance.Free;
if (fDependencyOrder[i] is TIocRegistrationInstance) and
(TIocRegistrationInstance(fDependencyOrder[i]).IsSingleton) then
TIocRegistrationInstance(fDependencyOrder[i]).Instance.Free;
fDependencyOrder[i].Free;
end;
end;
Expand Down
Loading

0 comments on commit 2bb4861

Please sign in to comment.