* Fix registry search for method name

This commit is contained in:
Michaël Van Canneyt 2021-12-20 13:26:08 +01:00
parent fd29f25bf1
commit 87a785daa0

View File

@ -1095,7 +1095,7 @@ begin
If Assigned(Owner) and ((AClassName='') or (CompareText(AClassName,Owner.name)=0)) then If Assigned(Owner) and ((AClassName='') or (CompareText(AClassName,Owner.name)=0)) then
begin begin
I:=0; I:=0;
While (Result=Nil) and (I<ComponentCount) do While (Result=Nil) and (I<Owner.ComponentCount) do
begin begin
C:=Owner.Components[i]; C:=Owner.Components[i];
If (C is TCustomJSONRPCHandler) and SameText(TCustomJSONRPCHandler(C).RPCMethodName,aMethodName) then If (C is TCustomJSONRPCHandler) and SameText(TCustomJSONRPCHandler(C).RPCMethodName,aMethodName) then
@ -1530,6 +1530,7 @@ Var
AClass : TCustomJSONRPCHandlerClass; AClass : TCustomJSONRPCHandlerClass;
DM : TDataModule; DM : TDataModule;
C : TComponent; C : TComponent;
I : Integer;
begin begin
Result:=Nil; Result:=Nil;
@ -1539,10 +1540,15 @@ begin
{$ifdef wmdebug}SendDebug(Format('Creating datamodule from class %d ',[Ord(Assigned(FDataModuleClass))]));{$endif} {$ifdef wmdebug}SendDebug(Format('Creating datamodule from class %d ',[Ord(Assigned(FDataModuleClass))]));{$endif}
DM:=FDataModuleClass.Create(AOwner); DM:=FDataModuleClass.Create(AOwner);
{$ifdef wmdebug}SendDebug(Format('Created datamodule from class %s ',[DM.ClassName]));{$endif} {$ifdef wmdebug}SendDebug(Format('Created datamodule from class %s ',[DM.ClassName]));{$endif}
C:=DM.FindComponent(FHandlerMethodName); I:=0;
If (C<>Nil) and (C is TCustomJSONRPCHandler) then While (Result=Nil) and (I<DM.ComponentCount) do
Result:=TCustomJSONRPCHandler(C) begin
else C:=DM.Components[i];
If (C is TCustomJSONRPCHandler) and SameText(TCustomJSONRPCHandler(C).RPCMethodName,FHandlerMethodName) then
Result:=TCustomJSONRPCHandler(C);
inc(I);
end;
If Result=Nil then
begin begin
FreeAndNil(DM); FreeAndNil(DM);
JSONRPCError(SErrUnknownJSONRPCMethodHandler,[FHandlerMethodName]); JSONRPCError(SErrUnknownJSONRPCMethodHandler,[FHandlerMethodName]);