QuickLib icon indicating copy to clipboard operation
QuickLib copied to clipboard

Access violation destroying TIocContainer

Open estrify opened this issue 2 years ago • 0 comments

You can reproduce the issue simply running the QuickIOC demo: an exception is thrown when "iocContainer.Free" is called.

Maybe the issue is related to the following line (module "Quick.IOC.pas", destructor TIocRegistrator.Destroy):

if (fDependencyOrder[i] is TIocRegistrationInstance) and (TIocRegistrationInstance(fDependencyOrder[i]).IsSingleton) then TIocRegistrationInstance(regs[i]).Instance.Free;

Since if it is replaced by the follwing, apparently the problem disappears:

if (fDependencyOrder[i] is TIocRegistrationInstance) and (TIocRegistrationInstance(fDependencyOrder[i]).IsSingleton) then TIocRegistrationInstance(fDependencyOrder[i]).Instance.Free;

Best regards,

estrify avatar Aug 29 '22 10:08 estrify