From d7ac63abd787637d95cd54553db7996a58ca9de3 Mon Sep 17 00:00:00 2001 From: Michael Van Canneyt Date: Fri, 21 Feb 2025 14:33:29 +0100 Subject: [PATCH] * Fix releasobjectid --- packages/job/src/job_browser.pp | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/packages/job/src/job_browser.pp b/packages/job/src/job_browser.pp index ed6789b..aa4d7d4 100644 --- a/packages/job/src/job_browser.pp +++ b/packages/job/src/job_browser.pp @@ -74,7 +74,6 @@ Type FGlobalObjects: TJSArray; // id to TJSObject FGlobalNames: TJSObject; // name to id FLocalObjects: TJSArray; - FFreeLocalIds: TJSArray; // free positions in FLocalObjects FOnCallBackJSError: TCallbackErrorJSEventHandler; FOnCallBackPasError: TCallbackErrorPasEventHandler; FStringResult: string; @@ -251,7 +250,6 @@ begin RegisterGlobalObjects; FLocalObjects:=TJSArray.new; FLocalObjects.push(nil); // allocate FLocalObjects[0] - FFreeLocalIds:=TJSArray.new; FFactories:=TJSObject.New; end; @@ -349,20 +347,10 @@ begin end; function TJSObjectBridge.RegisterLocalObject(Obj: TJSObject): TJOBObjectID; -var - NewId: JSValue; + begin - NewId:=FFreeLocalIds.pop; - if isUndefined(NewId) then - begin - NewId:=FLocalObjects.push(Obj)-1; - Result:=TJOBObjectID(NewId); - FLastAllocatedID:=Result; - end - else begin - Result:=TJOBObjectID(NewId); - FLocalObjects[Result]:=Obj; - end; + Result:=GetObjectID; + RegisterLocalObjectAt(Obj,Result); {$IFDEF VerboseJOB} writeln('TJSObjectBridge.RegisterLocalObject ',Result); {$ENDIF} @@ -814,7 +802,8 @@ begin if FLocalObjects[ObjId]=nil then raise EJOBBridge.Create('object already released'); FLocalObjects[ObjId]:=nil; - FFreeLocalIds.push(ObjId); + ReleaseJobID(ObjID); + Result:=JOBResult_Success; end; @@ -1306,7 +1295,6 @@ end; function TJSObjectBridge.GetStats: TJSObjectBridgeStats; begin Result.LastAllocatedID:=FLastAllocatedID; - Result.FreeIDCount:=FFreeLocalIds.Length; Result.LiveObjectCount:=FLocalObjects.Length; Result.GlobalObjectCount:=FGlobalObjects.Length; end;