realbasic-nug
[Top] [All Lists]

Re: Dangerous deallocation/circular reference...

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Dangerous deallocation/circular reference...
From: Erich Rast <Erich dot Rast at t-online dot de>
Date: Thu, 11 Jul 2002 20:47:57 +0200
I suppose I could have the Tickler break the circle instead, after the call to the Tickled, but I need to have some way of communicating that from the Tickled, which is the object that knows when the task is complete...

If the tickled object knows when the task is complete, it should be responsible for disposing the Tickler. So give the Tickler a method Dispose which stops it and sets the owning tickled object property to nil.

Tickler.Stop:

mode = 0

Tickler.Dispose:

Stop
owner = nil

So when a tickled object calls tickler.dispose, it may not re-use the tickler again but can safely set tickler = nil. After that, the tickler will get garbaged. (I'm not sure how smart RB is with running timers, so it makes sense to stop it before destroying it, even if it checks the owner object for nil before calling any method of it.)


Regards,

Erich


<Prev in Thread] Current Thread [Next in Thread>