diff options
| author | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2008-10-29 22:44:53 +0000 |
|---|---|---|
| committer | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2008-10-29 22:44:53 +0000 |
| commit | 0c59a4279f93f08fe95fca5f2e55f3e025f0cceb (patch) | |
| tree | 71e8c11f2a5487afe84d637d388d3cb060bc9ad5 /lib/base/ebase.cpp | |
| parent | 4edb65fafb64b52007598e05a1e5b16b75ea752c (diff) | |
| download | enigma2-0c59a4279f93f08fe95fca5f2e55f3e025f0cceb.tar.gz enigma2-0c59a4279f93f08fe95fca5f2e55f3e025f0cceb.zip | |
also use refcounting for eTimers
its now no more possible directly to call new eTimer .. or to embedded
eTimer.
to create a eTimer now eTimer::create must be used... to delete you must
call ->AddRef() after timer creation and ->Release when the timer is no more
needed. Or use ePtr<eTimer> to store the timer reference.. then its enough
to set the ePtr<eTimer> object to 0 when the timer is no more needed
Diffstat (limited to 'lib/base/ebase.cpp')
| -rw-r--r-- | lib/base/ebase.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/base/ebase.cpp b/lib/base/ebase.cpp index a66d1958..bd2ec589 100644 --- a/lib/base/ebase.cpp +++ b/lib/base/ebase.cpp @@ -39,7 +39,8 @@ void eSocketNotifier::stop() } } - // timer +DEFINE_REF(eTimer); + void eTimer::start(long msek, bool singleShot) { if (bActive) @@ -160,7 +161,12 @@ int eMainloop::processOneEvent(unsigned int twisted_timeout, PyObject **res, ePy { /* process all timers which are ready. first remove them out of the list. */ while (!m_timer_list.empty() && (poll_timeout = timeout_usec( m_timer_list.begin()->getNextActivation() ) ) <= 0 ) - m_timer_list.begin()->activate(); + { + eTimer *tmr = m_timer_list.begin(); + tmr->AddRef(); + tmr->activate(); + tmr->Release(); + } if (poll_timeout < 0) poll_timeout = 0; else /* convert us to ms */ @@ -403,7 +409,7 @@ eTimerPy_dealloc(eTimerPy* self) if (self->in_weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *) self); eTimerPy_clear(self); - delete self->tm; + self->tm->Release(); self->ob_type->tp_free((PyObject*)self); } @@ -411,7 +417,8 @@ static PyObject * eTimerPy_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { eTimerPy *self = (eTimerPy *)type->tp_alloc(type, 0); - self->tm = new eTimer(eApp); + self->tm = eTimer::create(eApp); + self->tm->AddRef(); self->in_weakreflist = NULL; return (PyObject *)self; } |
