On Tue, 08 Sep 2009 18:13:56 -0400, Saaa <em...@needmail.com> wrote:

Hope this one makes any sense :)

C c = new C;
C mouseOverObject = c;

int delegate() deleg = &mouseOverObject.getSomeVariable;
mouseOverObject = null;

int value;
void write()
{
if(deleg !is null) //how do I make this check for (mouseOverObject !is
null)?

if(mouseOverObject !is null)

That's the only way. A delegate does not magically become set to null when you set the original object to null or delete the original object. It is a separate pointer that is only set when you set it.

What you are asking is the equivalent of this:

int x = 5;
int y = x;

x = 0;

if(y != 0) // how do I check through y that x is now 0?

However, setting mouseOverObject to null does *not* destroy the object, as long as the delegate exists, it is still pointing to the object, so it will not be cleaned by the GC.

So your delegate is still valid as long as you don't delete mouseOverObject manually.

-Steve

Reply via email to