Skip to content

Commit cb649c8

Browse files
author
Diogo Aires
committed
Adjust on release instances when is object singleton and interfaced
1 parent 3fb5b84 commit cb649c8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Quick.IOC.pas

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,15 @@ destructor TIocRegistrator.Destroy;
467467
if fDependencyOrder[i] <> nil then
468468
begin
469469
//free singleton instances not interfaced
470-
if (fDependencyOrder[i] is TIocRegistrationInstance) and
471-
(TIocRegistrationInstance(fDependencyOrder[i]).IsSingleton) then
472-
TIocRegistrationInstance(fDependencyOrder[i]).Instance.Free;
470+
if (fDependencyOrder[i] is TIocRegistrationInstance) and
471+
(TIocRegistrationInstance(fDependencyOrder[i]).IsSingleton) then
472+
TIocRegistrationInstance(fDependencyOrder[i]).Instance.Free
473+
else
474+
//free singleton instances interfaced
475+
if (fDependencyOrder[i] is TIocRegistrationInterface) and
476+
(TIocRegistrationInterface(fDependencyOrder[i]).IsSingleton) and
477+
(Assigned(TIocRegistrationInterface(fDependencyOrder[i]).Instance)) then
478+
TIocRegistrationInterface(fDependencyOrder[i]).Instance._Release;
473479
fDependencyOrder[i].Free;
474480
end;
475481
end;

0 commit comments

Comments
 (0)