Hi,

That’s not a bug. That’s normal.

$oChildObject:=New object create a reference to a object store in $oChildObject

 OB SET($oParentObject;"ChildInformation";New object) push another reference 
into the $oParentObject but the old reference still exist because $oChildObject 
isn’t cleared.

you try :  $oParentObject.ChildInformation:=Null
try this  $oChildObject:=null

and read $oParentObject

Regards,

Olivier





> Le 21 févr. 2019 à 18:59, Drew Waddell via 4D_Tech <4d_tech@lists.4D.com> a 
> écrit :
>
> I am trying to figure out if this is a bug or not.  This is a watered down 
> version of something I am trying to do:
>
>                C_OBJECT($oParentObject;$oChildObject)
>
>                $oChildObject:=New object
>                $oParentObject:=New object
>                $oParentObject.ChildInformation:=$oChildObject
>                $oParentObject.ChildInformation.FirstName:="John"
>                $oParentObject.ChildInformation.LastName:="Smith"
>
> I want $oChildObject and $oParentObject.ChildInformation to remain the same 
> and should because of how the references work, so at this moment each are 
> {FirstName:John,LastName:Smith}.  Let say something happens like maybe there 
> is a Clear button, how would one clear the child object?
>
> First, I wanted to do this:
>
>                $oParentObject.ChildInformation:=Null // $oChildObject = 
> {FirstName:John,LastName:Smith}
>
> Okay, I thought that was the correct way to clear both objects but maybe 
> there is a different way so maybe this?
>
>                OB SET($oParentObject;"ChildInformation";New object) // 
> $oChildObject = {FirstName:John,LastName:Smith}
>
> Nope, again the child object with $oParentObject is cleared but $oChildObject 
> remains {FirstName:John,LastName:Smith}.  So do I really have to loop over 
> all properties and remove them individually?
>
>                OB REMOVE($oParentObject.ChildInformation;"FirstName")
>                OB REMOVE($oParentObject.ChildInformation;"LastName")  // 
> $oChildObject = {}
>
> Finally when I make a change in the $oParentObject.ChildInformation the 
> referenced object $oChildObject is also updated.
>
> Is this a bug?  Shouldn't the :=Null work and also change the $oChildObject 
> variable?
>
> Thanks,
> Drew
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to