Confusion with instances and events

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

Confusion with instances and events

Bob.Cowdery

Hi

 

I am getting myself pretty confused at the moment. Hopefully, someone can unconfuse me.

 

I have an application that essentially is a collection of specialised morphs that are connected together to form the application. I am adding some event mechanisms into this such that state changes are broadcast to interested parties. The actual mechanism works fine on all my morphs except one. Each morph is constructed exactly the same, there is a control class which creates the morph and does ‘openInWorld’. At present I create all these components (for want of a better word) in a workspace. As I had trouble with cleaning up stray references I do not assign these components to a variable in the workspace when I create them. What I have discovered is that the component that does not receive the event DOES receive the event if, when I create it I do assign it to a variable. To be clear the event is sent to the morph but the hook and the target is set up by the owning component class.

 

The odd thing is that all the other components work without doing this assignment. Another oddity that may shed more light is that if I do ‘Pan allInstances’ I get an empty array even though I have done ‘Pan new.’ (Pan being the class that does not work) in the workspace. If I do this to another component ‘OffsetDisp allInstances’ I get the instances even though it is created exactly the same way and has the same structure. To prove this I created another OffsetDisp and got another instance.

 

I have some other components which are created like so in the workspace ‘SDRButtonContainer newWithInteractors: (SDRFilterButtonBox new).’. This simply has a class initialise which takes a bunch of buttons. Odd thing is the events work here but ‘SDRButtonContainer allInstances’ still gives me nothing. I don’t know therefore if these things are linked or separate problems.

 

It’s the inconsistency that is confusing. On the face of it I have three components with very similar structure that all behave differently.

 

Thanks for any help

 

Bob

*** Confidentiality Notice *** Proprietary/Confidential
Information belonging to CGI Group Inc. and its affiliates
may be contained in this message. If you are not a recipient
indicated or intended in this message (or responsible for
delivery of this message to such person), or you think for
any reason that this message may have been addressed to you
in error, you may not use or copy or deliver this message
to anyone else.  In such case, you should destroy this
message and are asked to notify the sender by reply email.



Reply | Threaded
Open this post in threaded view
|

Re: Confusion with instances and events

Tom Phoenix
On 5/1/06, Cowdery, Bob [UK] <[hidden email]> wrote:

> The odd thing is that all the other components work without doing this
> assignment. Another oddity that may shed more light is that if I do 'Pan
> allInstances' I get an empty array even though I have done 'Pan new.'

This sounds as if your object was garbage collected. If you want to
keep your object, store it somewhere. Objects that aren't stored
anywhere get cleaned up.

Hope this helps!

--Tom Phoenix

Reply | Threaded
Open this post in threaded view
|

Re: Confusion with instances and events

Ralph Johnson
In reply to this post by Bob.Cowdery


On 5/1/06, Cowdery, Bob [UK] <[hidden email]> wrote:

I have some other components which are created like so in the workspace 'SDRButtonContainer newWithInteractors: (SDRFilterButtonBox new).'. This simply has a class initialise which takes a bunch of buttons. Odd thing is the events work here but 'SDRButtonContainer allInstances' still gives me nothing. I don't know therefore if these things are linked or separate problems.

 
There isn't enough information for me to figure out your main problem, but I think I know this one.
 
I bet that newWithInteractors: does not actually create an instance of SDRButtonContainer.  You say it "ismply has a class initialise" so I think you are just storing the arguments in a variable of the class, but do not actually create an instance of the class.  Note that SDRButtonContainer is a class, it is not itself a SDRButtonContainer.  So, it has not instances and allInstances SHOULD return nothing.
 
In general, we will need more info to debug this.  Give more code.
 
-Ralph

 


Reply | Threaded
Open this post in threaded view
|

RE: Confusion with instances and events

Bob.Cowdery
In reply to this post by Bob.Cowdery

 

On 5/1/06, Cowdery, Bob [UK] <[hidden email]> wrote:

I have some other components which are created like so in the workspace 'SDRButtonContainer newWithInteractors: (SDRFilterButtonBox new).'. This simply has a class initialise which takes a bunch of buttons. Odd thing is the events work here but 'SDRButtonContainer allInstances' still gives me nothing. I don't know therefore if these things are linked or separate problems.

 Ralph Johnson wrote:

There isn't enough information for me to figure out your main problem, but I think I know this one.

 

I bet that newWithInteractors: does not actually create an instance of SDRButtonContainer.  You say it "ismply has a class initialise" so I think you are just storing the arguments in a variable of the class, but do not actually create an instance of the class.  Note that SDRButtonContainer is a class, it is not itself a SDRButtonContainer.  So, it has not instances and allInstances SHOULD return nothing.

 

In general, we will need more info to debug this.  Give more code.

 

It is being created Ralph, but see below.

 

Tom Phonex wrote:

This sounds as if your object was garbage collected. If you want to keep your object, store it somewhere. Objects that aren't stored anywhere get cleaned up.

 

Well, it’s the obvious reason, but I couldn’t see why the behavior was different. Now I can. Some components set maps that create an indirect reference to the parent, others don’t. The ones that don’t do get garbage collected which up to now hasn’t mattered because all calls in these components are to the morph not the parent. I think I will stop doing this stuff in the workspace and write a script to properly create and clean up the instances.

 

Thanks both for your help.

 

Bob


 

*** Confidentiality Notice *** Proprietary/Confidential
Information belonging to CGI Group Inc. and its affiliates
may be contained in this message. If you are not a recipient
indicated or intended in this message (or responsible for
delivery of this message to such person), or you think for
any reason that this message may have been addressed to you
in error, you may not use or copy or deliver this message
to anyone else.  In such case, you should destroy this
message and are asked to notify the sender by reply email.