[compiz] [PATCH] Remove timeout callback
Mike Dransfield
mike at blueroot.co.uk
Mon Apr 23 08:14:40 PDT 2007
David Reveman wrote:
> On Mon, 2007-04-23 at 14:28 +0100, Mike Dransfield wrote:
>
>> While working on the python plugin, I realised that the
>> timeout system does not allow for notification when a timeout
>> is removed. This has been fine up until now because he closures
>> never needed to be cleaned up.
>>
>> In the python plugin, I pass through a custom structure which
>> needs to be cleaned up if the timeout is removed. This is almost
>> certainly the cause of some horrible memory leaks for me.
>>
>> The attached patch is a simple solution to the problem. I think
>> it should be good enough for most situations.
>>
>> I could maintain some sort of lookup inside my plugin, but I think
>> other plugins would benefit from this.
>>
>> It is OK to go in or were there any comments?
>>
>
> Timeouts are only removed as a result of the timeout call-back function
> returning FALSE. So unless I'm missing something, all cleanup can be
> done in the regular call-back function before returning FALSE.
>
>
The pyplane (and the original plane) use a timeout which gets
canceled if the user quickly switches back to another viewport.
It is not a problem for plane because the closure is a CompScreen
which does not need to be cleaned up.
The plugins call compRemoveTimeout to stop it. I'm not sure if this
is right in this case, but it seems that it would be useful to stop a
timeout before it expires, and it makes it easy to clean up the closure
without having to maintain a lookup table of handles to closures.
More information about the compiz
mailing list