Removing Objects from TSpace

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Removing Objects from TSpace

Michael Kleiber
Hello All,

I recently began programming with the 1.0 Croquet and quickly stumbled
upon a problem. How do I remove Objects (TFrames) after I added them
dynamically to my root space?

Following the examples (as in Import Object) I add new objects by issuing:
  replica := hand world ownerMorph harness avatar replica.
  root := replica future root.
  root future addChild: myTFrame.

When I keep myTFrame as an instance Variable and try to check later if
the space already has this particular object I do not get reasonable
answers - trying to #removeChild: does nothing:

  root future hasChild: myTFrame
returns a TFarRef with value false

  root future removeChild: myTFrame
does nothing

So how would I dynamically add and remove objects from a space?

Michael

Reply | Threaded
Open this post in threaded view
|

Re: Removing Objects from TSpace

Andreas.Raab
Michael Kleiber wrote:
> I recently began programming with the 1.0 Croquet and quickly stumbled
> upon a problem. How do I remove Objects (TFrames) after I added them
> dynamically to my root space?

Just the way you did it. Using addChild:, removeChild: and hasChild: is
exactly correct.

> When I keep myTFrame as an instance Variable and try to check later if
> the space already has this particular object I do not get reasonable
> answers - trying to #removeChild: does nothing:
>
>  root future hasChild: myTFrame
> returns a TFarRef with value false

This is odd. It should definitely work unless there is something funky
with your replica in the above. Try the following to see if it works:
   harness activeSpace future addChild: myFrame.
   p := harness activeSpace future hasChild: myFrame.
   p wait. "until completed"
   p value ifFalse:[self error: 'Something is horribly broken'].

The only difference to your code is that I'm using
CroquetHarness>>activeSpace instead of querying the replica's root. This
shouldn't be much of a difference but I have successfully used the above
pattern and I don't think I've ever used the pattern you were using. If
this variant works and yours doesn't then we know where to look.

Cheers,
   - Andreas