From 846ac6f77aa5f3ca2619c8467988c0df0957bc56 Mon Sep 17 00:00:00 2001 From: inoussa Date: Thu, 13 Feb 2025 10:30:43 +0000 Subject: [PATCH] Allow assignment for readonly object property. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9637 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- wst/trunk/base_service_intf.pas | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/wst/trunk/base_service_intf.pas b/wst/trunk/base_service_intf.pas index b636afd2c..32669d4ce 100644 --- a/wst/trunk/base_service_intf.pas +++ b/wst/trunk/base_service_intf.pas @@ -5224,7 +5224,7 @@ begin p := propList^[i]; sp := GetPropInfo(Source,p^.Name); if Assigned(sp) and Assigned(sp^.GetProc) and - Assigned(p^.SetProc) + ((p^.PropType^.Kind = tkClass) or Assigned(p^.SetProc)) then begin case p^.PropType^.Kind of tkInt64{$IFDEF HAS_QWORD} ,tkQWord{$ENDIF} : @@ -5241,19 +5241,21 @@ begin begin srcObj := GetObjectProp(Source,p^.Name); dstObj := GetObjectProp(Self,p^.Name); - if ( not Assigned(dstObj) ) and - ( Assigned(srcObj) and srcObj.InheritsFrom(TAbstractComplexRemotable) ) - then begin - dstObj := TAbstractComplexRemotableClass(srcObj.ClassType).Create(); - SetObjectProp(Self,p,dstObj); - end; - if Assigned(dstObj) then begin - if ( srcObj = nil ) then begin - FreeAndNil(dstObj); + if (dstObj <> nil) then begin + if ( not Assigned(dstObj) ) and + ( Assigned(srcObj) and srcObj.InheritsFrom(TAbstractComplexRemotable) ) + then begin + dstObj := TAbstractComplexRemotableClass(srcObj.ClassType).Create(); SetObjectProp(Self,p,dstObj); - end else begin - if dstObj.InheritsFrom(TPersistent) and srcObj.InheritsFrom(TPersistent) then - TPersistent(dstObj).Assign(TPersistent(srcObj)); + end; + if Assigned(dstObj) then begin + if ( srcObj = nil ) then begin + FreeAndNil(dstObj); + SetObjectProp(Self,p,dstObj); + end else begin + if dstObj.InheritsFrom(TPersistent) and srcObj.InheritsFrom(TPersistent) then + TPersistent(dstObj).Assign(TPersistent(srcObj)); + end; end; end; end;