From 80424c8250f09188a7074337a5d10964c95e5e1a Mon Sep 17 00:00:00 2001 From: Roland Bengtsson Date: Sat, 7 Dec 2024 12:55:05 +0200 Subject: [PATCH] Fixed potential bug in destruction order. #20 --- Source/BoldElements.pas | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/BoldElements.pas b/Source/BoldElements.pas index 7de6606..b190f35 100644 --- a/Source/BoldElements.pas +++ b/Source/BoldElements.pas @@ -974,11 +974,16 @@ constructor TBoldExternalVariable.Create(AEvaluator: TBoldEvaluator; const AName end; destructor TBoldExternalVariable.Destroy; +var + vEvaluator: TBoldEvaluator; begin fSubscriber.Free; - if Assigned(fEvaluator) then - fEvaluator.UndefineVariable(self); - fEvaluator := nil; + vEvaluator := fEvaluator; + if Assigned(vEvaluator) then + begin + fEvaluator := nil; + vEvaluator.UndefineVariable(self); + end; inherited; end;