Cleaning up intervals

If I’m cleaning up a custom class that contained intervals, do I need to explicitly remove the reference to the interval? I figure I probably don’t, but I thought I’d ask.

You do if the interval might contain back pointers to the class instance itself (which is not uncommon). For instance, any Func intervals for class methods will keep a back pointer to the class instance. Likewise, any intervals with “self” as an extraArg will keep a back pointer.

David

Okay, then if I’m using projectile intervals to fling parts of a vehicle around after it explodes, and calling .removeNode() on those pieces once the intervals finish, I shouldn’t have to worry about it. Thanks.

If your class contains a custom finalizer (‘del’), you will also need to explicitly remove the references.

There is some chance you don’t need, strictly, to keep a reference to the interval in your class; in which case you would not need to explicitly break it. In one program, I create an interval, call ‘start’, then discard it (!), leaving it to be cleaned up when Panda’s internal references are removed.

In short, no “self.interval”. But if you might need “self.interval.stop( )” or others, you’ll need the reference, thus need to break it; this again only if you have a del.