[Pidgin] #12440: perl Purple::timeout_add multiplies calls to given subroutine (using dummy plugin code from doxygen)
Pidgin
trac at pidgin.im
Mon Apr 11 07:44:11 EDT 2011
#12440: perl Purple::timeout_add multiplies calls to given subroutine (using dummy
plugin code from doxygen)
-------------------------+--------------------------------------------------
Reporter: marcelser | Owner:
Type: defect | Status: new
Milestone: | Component: plugins
Version: 2.7.1 | Resolution:
Keywords: plugins bug |
-------------------------+--------------------------------------------------
Comment(by caglaroral):
Replying to [comment:2 datallah]:
>
> If you look at the
[http://developer.pidgin.im/doxygen/dev/html/eventloop_8h.html#adefb8b6d8b677ba989e47cbf8a05806
documentation for purple_timeout_add] you'll see that it will keep
repeating the timeout on the same interval until the callback function
returns `FALSE`, so the behavior is actually correct according to the API
documentation.
>
> Unfortunately the (wildly out of date) Perl HOWTO has incorrect
information about the behavior of the `Purple::timeout_add()` function.
I'll keep this ticket open as a reminder to fix it.
No matter what you return from the callback function the timeout_add
function calls the callback function only once. So at the end of the
callback you have to put timeout_add function setup the timer again. This
causes callback function to be called multiple times at a time.
{{{
if (timeout){
Purple::timeout_remove($timeout);
$timeout = 0;
}
$timeout = Purple::timeout_add($plugin, 120, \&timeout_cb, $plugin);
}}}
Purple::timeout_remove before adding a new timeout at the end of the
callback function might be a workaround. Its working fine with my plugin.
--
Ticket URL: <http://developer.pidgin.im/ticket/12440#comment:4>
Pidgin <http://pidgin.im>
Pidgin
More information about the Tracker
mailing list