VirtualBox

vbox的更動 31604 路徑 trunk/src/libs/xpcom18a4/python


忽略:
時間撮記:
2010-8-12 下午03:17:54 (14 年 以前)
作者:
vboxsync
訊息:

waitForEvents: Don't return None, another test.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/libs/xpcom18a4/python/src/module/_xpcom.cpp

    r31601 r31604  
    502502PyXPCOMMethod_WaitForEvents(PyObject *self, PyObject *args)
    503503{
    504   PRInt32 aTimeout;
    505 
    506   if (!PyArg_ParseTuple(args, "i", &aTimeout))
    507     return NULL; /** @todo throw exception */
    508 
    509   int rc;
    510   com::EventQueue* aEventQ = com::EventQueue::getMainEventQueue();
    511   NS_WARN_IF_FALSE(aEventQ != nsnull, "Null main event queue");
    512   if (!aEventQ)
    513       return NULL;
    514 
    515   Py_BEGIN_ALLOW_THREADS
    516   rc = aEventQ->processEventQueue(aTimeout < 0 ? RT_INDEFINITE_WAIT : (uint32_t)aTimeout);
    517   Py_END_ALLOW_THREADS
    518   if (RT_SUCCESS(rc))
    519       return PyInt_FromLong(0);
    520 
    521   if (   rc == VERR_TIMEOUT
    522       || rc == VERR_INTERRUPTED)
    523       return PyInt_FromLong(1);
    524 
    525   return PyInt_FromLong(2);
     504    PRInt32 aTimeout;
     505
     506    if (!PyArg_ParseTuple(args, "i", &aTimeout))
     507    {
     508        PyErr_SetString(PyExc_TypeError, "the timeout argument is not an integer");
     509        return NULL;
     510    }
     511
     512    int rc;
     513    com::EventQueue* aEventQ = com::EventQueue::getMainEventQueue();
     514    NS_WARN_IF_FALSE(aEventQ != nsnull, "Null main event queue");
     515    if (!aEventQ)
     516        {
     517        PyErr_SetString(PyExc_TypeError, "the main event queue is NULL");
     518        return NULL;
     519        }
     520
     521    Py_BEGIN_ALLOW_THREADS
     522    rc = aEventQ->processEventQueue(aTimeout < 0 ? RT_INDEFINITE_WAIT : (uint32_t)aTimeout);
     523    Py_END_ALLOW_THREADS
     524    if (RT_SUCCESS(rc))
     525        return PyInt_FromLong(0);
     526
     527    if (   rc == VERR_TIMEOUT
     528        || rc == VERR_INTERRUPTED)
     529        return PyInt_FromLong(1);
     530
     531    if (rc == VERR_INVALID_CONTEXT)
     532        {
     533        PyErr_SetString(PyExc_Exception, "wrong thread, use the main thread");
     534                return NULL;
     535        }
     536
     537    return PyInt_FromLong(2);
    526538}
    527539
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette