* Allow to call DebugLiveObjects using object id -1

This commit is contained in:
Michael Van Canneyt 2024-09-20 10:23:24 +02:00
parent b0dfc31b05
commit 1efaac6c8d

View File

@ -118,7 +118,7 @@ Type
Procedure RegisterJSObjectFactory(const aName : string; aFunc : TJSObjectFactory); overload; Procedure RegisterJSObjectFactory(const aName : string; aFunc : TJSObjectFactory); overload;
Function GetJOBResult(v: jsvalue): TJOBResult; Function GetJOBResult(v: jsvalue): TJOBResult;
Function GetStats : TJSObjectBridgeStats; Function GetStats : TJSObjectBridgeStats;
Procedure DumpLiveObjects; Procedure DumpLiveObjects(S : String = '');
property CallbackHandler: TJOBCallback read FCallbackHandler write FCallbackHandler; property CallbackHandler: TJOBCallback read FCallbackHandler write FCallbackHandler;
property OnCallBackJSError : TCallbackErrorJSEventHandler read FOnCallBackJSError Write FOnCallBackJSError; property OnCallBackJSError : TCallbackErrorJSEventHandler read FOnCallBackJSError Write FOnCallBackJSError;
property OnCallBackPasError : TCallbackErrorPasEventHandler read FOnCallBackPasError Write FOnCallBackPasError; property OnCallBackPasError : TCallbackErrorPasEventHandler read FOnCallBackPasError Write FOnCallBackPasError;
@ -753,16 +753,24 @@ var
begin begin
S:=Env.GetUTF8StringFromMem(aMessage,aMessageLen); S:=Env.GetUTF8StringFromMem(aMessage,aMessageLen);
Obj:=FindObject(ObjId); if ObjID=-1 then
if not assigned(Obj) then
begin begin
Result:=JOBResult_UnknownObjId; DumpLiveObjects(S);
console.warn('Cannot find object ',ObjId); Result:=JOBResult_Success;
end end
else else
begin begin
console.debug(S,' dumping object ',ObjID,' : ',Obj); Obj:=FindObject(ObjId);
Result:=JOBResult_Success; if not assigned(Obj) then
begin
Result:=JOBResult_UnknownObjId;
console.warn('Cannot find object ',ObjId);
end
else
begin
console.debug(S,' dumping object ',ObjID,' : ',Obj);
Result:=JOBResult_Success;
end;
end; end;
end; end;
@ -1217,11 +1225,11 @@ begin
Result.GlobalObjectCount:=FGlobalObjects.Length; Result.GlobalObjectCount:=FGlobalObjects.Length;
end; end;
procedure TJSObjectBridge.DumpLiveObjects; procedure TJSObjectBridge.DumpLiveObjects(S: String);
begin begin
Console.Log('Local objects'); Console.Log(S,'Local objects:');
Console.debug(FLocalObjects); Console.debug(FLocalObjects);
Console.Log('Global objects'); Console.Log(S,'Global objects:');
Console.debug(FGlobalObjects); Console.debug(FGlobalObjects);
end; end;