git.cweiske.de
/
enigma2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
don't crash when exitting dvd image selection without selection
[enigma2.git]
/
lib
/
base
/
ebase.cpp
diff --git
a/lib/base/ebase.cpp
b/lib/base/ebase.cpp
index 724e9dca8dbda39d921c233e5cb74587207d7470..bd2ec589227946199b60071faf4ab4617dc850ba 100644
(file)
--- a/
lib/base/ebase.cpp
+++ b/
lib/base/ebase.cpp
@@
-8,9
+8,11
@@
#include <lib/base/elock.h>
#include <lib/gdi/grc.h>
#include <lib/base/elock.h>
#include <lib/gdi/grc.h>
+DEFINE_REF(eSocketNotifier);
+
eSocketNotifier::eSocketNotifier(eMainloop *context, int fd, int requested, bool startnow): context(*context), fd(fd), state(0), requested(requested)
{
eSocketNotifier::eSocketNotifier(eMainloop *context, int fd, int requested, bool startnow): context(*context), fd(fd), state(0), requested(requested)
{
- if (startnow)
+ if (startnow)
start();
}
start();
}
@@
-31,12
+33,14
@@
void eSocketNotifier::start()
void eSocketNotifier::stop()
{
if (state)
void eSocketNotifier::stop()
{
if (state)
+ {
+ state=0;
context.removeSocketNotifier(this);
context.removeSocketNotifier(this);
-
- state=0;
+ }
}
}
- // timer
+DEFINE_REF(eTimer);
+
void eTimer::start(long msek, bool singleShot)
{
if (bActive)
void eTimer::start(long msek, bool singleShot)
{
if (bActive)
@@
-131,8
+135,13
@@
void eMainloop::removeSocketNotifier(eSocketNotifier *sn)
int fd = sn->getFD();
std::map<int,eSocketNotifier*>::iterator i(notifiers.find(fd));
if (i != notifiers.end())
int fd = sn->getFD();
std::map<int,eSocketNotifier*>::iterator i(notifiers.find(fd));
if (i != notifiers.end())
- return notifiers.erase(i);
- eFatal("removed socket notifier which is not present");
+ {
+ notifiers.erase(i);
+ return;
+ }
+ for (i = notifiers.begin(); i != notifiers.end(); ++i)
+ eDebug("fd=%d, sn=%d", i->second->getFD(), (void*)i->second);
+ eFatal("removed socket notifier which is not present, fd=%d", fd);
}
int eMainloop::processOneEvent(unsigned int twisted_timeout, PyObject **res, ePyObject additional)
}
int eMainloop::processOneEvent(unsigned int twisted_timeout, PyObject **res, ePyObject additional)
@@
-152,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 )
{
/* 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 */
if (poll_timeout < 0)
poll_timeout = 0;
else /* convert us to ms */
@@
-175,6
+189,7
@@
int eMainloop::processOneEvent(unsigned int twisted_timeout, PyObject **res, ePy
// build the poll aray
pollfd pfd[fdcount]; // make new pollfd array
std::map<int,eSocketNotifier*>::iterator it = notifiers.begin();
// build the poll aray
pollfd pfd[fdcount]; // make new pollfd array
std::map<int,eSocketNotifier*>::iterator it = notifiers.begin();
+
int i=0;
for (; i < nativecount; ++i, ++it)
{
int i=0;
for (; i < nativecount; ++i, ++it)
{
@@
-228,9
+243,13
@@
int eMainloop::processOneEvent(unsigned int twisted_timeout, PyObject **res, ePy
if (it != notifiers.end()
&& it->second->state == 1) // added and in poll
{
if (it != notifiers.end()
&& it->second->state == 1) // added and in poll
{
- int req = it->second->getRequested();
- if (pfd[i].revents & req)
- it->second->activate(pfd[i].revents & req);
+ eSocketNotifier *sn = it->second;
+ int req = sn->getRequested();
+ if (pfd[i].revents & req) {
+ sn->AddRef();
+ sn->activate(pfd[i].revents & req);
+ sn->Release();
+ }
pfd[i].revents &= ~req;
}
if (pfd[i].revents & (POLLERR|POLLHUP|POLLNVAL))
pfd[i].revents &= ~req;
}
if (pfd[i].revents & (POLLERR|POLLHUP|POLLNVAL))
@@
-368,7
+387,7
@@
struct eTimerPy
static int
eTimerPy_traverse(eTimerPy *self, visitproc visit, void *arg)
{
static int
eTimerPy_traverse(eTimerPy *self, visitproc visit, void *arg)
{
- PyObject *obj = self->tm->timeout.get
(true
);
+ PyObject *obj = self->tm->timeout.get
Steal(
);
if (obj) {
Py_VISIT(obj);
}
if (obj) {
Py_VISIT(obj);
}
@@
-378,7
+397,7
@@
eTimerPy_traverse(eTimerPy *self, visitproc visit, void *arg)
static int
eTimerPy_clear(eTimerPy *self)
{
static int
eTimerPy_clear(eTimerPy *self)
{
- PyObject *obj = self->tm->timeout.get(true);
+ PyObject *obj = self->tm->timeout.get
Steal
(true);
if (obj)
Py_CLEAR(obj);
return 0;
if (obj)
Py_CLEAR(obj);
return 0;
@@
-390,7
+409,7
@@
eTimerPy_dealloc(eTimerPy* self)
if (self->in_weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
eTimerPy_clear(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);
}
self->ob_type->tp_free((PyObject*)self);
}
@@
-398,7
+417,8
@@
static PyObject *
eTimerPy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
eTimerPy *self = (eTimerPy *)type->tp_alloc(type, 0);
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;
}
self->in_weakreflist = NULL;
return (PyObject *)self;
}
@@
-575,7
+595,7
@@
struct eSocketNotifierPy
static int
eSocketNotifierPy_traverse(eSocketNotifierPy *self, visitproc visit, void *arg)
{
static int
eSocketNotifierPy_traverse(eSocketNotifierPy *self, visitproc visit, void *arg)
{
- PyObject *obj = self->sn->activated.get
(true
);
+ PyObject *obj = self->sn->activated.get
Steal(
);
if (obj)
Py_VISIT(obj);
return 0;
if (obj)
Py_VISIT(obj);
return 0;
@@
-584,7
+604,7
@@
eSocketNotifierPy_traverse(eSocketNotifierPy *self, visitproc visit, void *arg)
static int
eSocketNotifierPy_clear(eSocketNotifierPy *self)
{
static int
eSocketNotifierPy_clear(eSocketNotifierPy *self)
{
- PyObject *obj = self->sn->activated.get(true);
+ PyObject *obj = self->sn->activated.get
Steal
(true);
if (obj)
Py_CLEAR(obj);
return 0;
if (obj)
Py_CLEAR(obj);
return 0;
@@
-596,7
+616,7
@@
eSocketNotifierPy_dealloc(eSocketNotifierPy* self)
if (self->in_weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
eSocketNotifierPy_clear(self);
if (self->in_weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
eSocketNotifierPy_clear(self);
-
delete self->sn
;
+
self->sn->Release()
;
self->ob_type->tp_free((PyObject*)self);
}
self->ob_type->tp_free((PyObject*)self);
}
@@
-620,7
+640,8
@@
eSocketNotifierPy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
else if (size < 2 || !PyArg_ParseTuple(args, "ii", &fd, &req))
return NULL;
}
else if (size < 2 || !PyArg_ParseTuple(args, "ii", &fd, &req))
return NULL;
- self->sn = new eSocketNotifier(eApp, fd, req, immediate_start);
+ self->sn = eSocketNotifier::create(eApp, fd, req, immediate_start);
+ self->sn->AddRef();
self->in_weakreflist = NULL;
return (PyObject *)self;
}
self->in_weakreflist = NULL;
return (PyObject *)self;
}
@@
-753,9
+774,7
@@
static PyMethodDef module_methods[] = {
void eBaseInit(void)
{
void eBaseInit(void)
{
- PyObject* m;
-
- m = Py_InitModule3("eBaseImpl", module_methods,
+ PyObject* m = Py_InitModule3("eBaseImpl", module_methods,
"Module that implements some enigma classes with working cyclic garbage collection.");
if (m == NULL)
"Module that implements some enigma classes with working cyclic garbage collection.");
if (m == NULL)