Browse Source

Fix AV in IOC for Singleton non-interfaced class

A non-interfaced class registered in the IOC as Singleton, was raising an AV when the container was freed
jkour 2 years ago
parent
commit
2bb48614b9
2 changed files with 69 additions and 15 deletions
  1. 3 1
      Quick.IOC.pas
  2. 66 14
      samples/delphi/QuickIOC/IOCdemo.dproj

+ 3 - 1
Quick.IOC.pas

@@ -442,7 +442,9 @@ begin
     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;

File diff suppressed because it is too large
+ 66 - 14
samples/delphi/QuickIOC/IOCdemo.dproj


Some files were not shown because too many files changed in this diff