diff options
| author | Felix Geyer <debfx-pkg@fobos.de> | 2010-10-12 15:58:30 +0200 |
|---|---|---|
| committer | Felix Geyer <debfx-pkg@fobos.de> | 2010-10-12 15:58:30 +0200 |
| commit | 7f230f4ac2a1b544b47ded0584c22822b9bd65d7 (patch) | |
| tree | ee5808929787047784013befd706131196a30d1d /src/libs/xpcom18a4/python | |
| parent | adf97a4e6386ea334ce8d77f0cde3b92454b9fa5 (diff) | |
| download | virtualbox-7f230f4ac2a1b544b47ded0584c22822b9bd65d7.tar.gz | |
Imported Upstream version 3.2.10-dfsgupstream/3.2.10-dfsg
Diffstat (limited to 'src/libs/xpcom18a4/python')
| -rw-r--r-- | src/libs/xpcom18a4/python/src/module/_xpcom.cpp | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/src/libs/xpcom18a4/python/src/module/_xpcom.cpp b/src/libs/xpcom18a4/python/src/module/_xpcom.cpp index dd756fdc2..7e4c462b2 100644 --- a/src/libs/xpcom18a4/python/src/module/_xpcom.cpp +++ b/src/libs/xpcom18a4/python/src/module/_xpcom.cpp @@ -501,28 +501,40 @@ PyObject *LogConsoleMessage(PyObject *self, PyObject *args) static PyObject* PyXPCOMMethod_WaitForEvents(PyObject *self, PyObject *args) { - PRInt32 aTimeout; + PRInt32 aTimeout; - if (!PyArg_ParseTuple(args, "i", &aTimeout)) - return NULL; /** @todo throw exception */ + if (!PyArg_ParseTuple(args, "i", &aTimeout)) + { + PyErr_SetString(PyExc_TypeError, "the timeout argument is not an integer"); + return NULL; + } - int rc; - com::EventQueue* aEventQ = com::EventQueue::getMainEventQueue(); - NS_WARN_IF_FALSE(aEventQ != nsnull, "Null main event queue"); - if (!aEventQ) - return NULL; + int rc; + com::EventQueue* aEventQ = com::EventQueue::getMainEventQueue(); + NS_WARN_IF_FALSE(aEventQ != nsnull, "Null main event queue"); + if (!aEventQ) + { + PyErr_SetString(PyExc_TypeError, "the main event queue is NULL"); + return NULL; + } + + Py_BEGIN_ALLOW_THREADS + rc = aEventQ->processEventQueue(aTimeout < 0 ? RT_INDEFINITE_WAIT : (uint32_t)aTimeout); + Py_END_ALLOW_THREADS + if (RT_SUCCESS(rc)) + return PyInt_FromLong(0); - Py_BEGIN_ALLOW_THREADS - rc = aEventQ->processEventQueue(aTimeout < 0 ? RT_INDEFINITE_WAIT : (uint32_t)aTimeout); - Py_END_ALLOW_THREADS - if (RT_SUCCESS(rc)) - return PyInt_FromLong(0); + if ( rc == VERR_TIMEOUT + || rc == VERR_INTERRUPTED) + return PyInt_FromLong(1); - if ( rc == VERR_TIMEOUT - || rc == VERR_INTERRUPTED) - return PyInt_FromLong(1); + if (rc == VERR_INVALID_CONTEXT) + { + PyErr_SetString(PyExc_Exception, "wrong thread, use the main thread"); + return NULL; + } - return NULL; /** @todo throw correct exception */ + return PyInt_FromLong(2); } static PyObject* @@ -533,9 +545,8 @@ PyXPCOMMethod_InterruptWait(PyObject *self, PyObject *args) if (!aEventQ) return NULL; - aEventQ->interruptEventQueueProcessing(); - - return PyInt_FromLong(0); + int rc = aEventQ->interruptEventQueueProcessing(); + return PyBool_FromLong(RT_SUCCESS(rc)); } static void deinitVBoxPython(); |
