VideoTexture: exception in C++ was not returning an error in Python. Added function...
authorBenoit Bolsee <benoit.bolsee@online.be>
Sun, 24 May 2009 23:12:38 +0000 (23:12 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Sun, 24 May 2009 23:12:38 +0000 (23:12 +0000)
source/gameengine/VideoTexture/ImageBase.cpp
source/gameengine/VideoTexture/ImageBuff.cpp
source/gameengine/VideoTexture/ImageMix.cpp
source/gameengine/VideoTexture/Texture.cpp
source/gameengine/VideoTexture/VideoFFmpeg.cpp
source/gameengine/VideoTexture/blendVideoTex.cpp

index dcca20de24aa4dded84a6752e5c6d6de91862c3f..5e2841271a6c0b7fbac515d9db216018421eba51 100644 (file)
@@ -437,7 +437,9 @@ PyObject * Image_getSource (PyImage * self, PyObject * args)
 {
        // get arguments
        char * id;
-       if (self->m_image != NULL && PyArg_ParseTuple(args, "s", &id))
+       if (!PyArg_ParseTuple(args, "s:getSource", &id))
+               return NULL;
+       if (self->m_image != NULL)
        {
                // get source object
                PyObject * src = reinterpret_cast<PyObject*>(self->m_image->getSource(id));
@@ -460,7 +462,9 @@ PyObject * Image_setSource (PyImage * self, PyObject * args)
        // get arguments
        char * id;
        PyObject * obj;
-       if (self->m_image != NULL && PyArg_ParseTuple(args, "sO", &id, &obj))
+       if (!PyArg_ParseTuple(args, "sO:setSource", &id, &obj))
+               return NULL;
+       if (self->m_image != NULL)
        {
                // check type of object
                if (pyImageTypes.in(obj->ob_type))
index c8e62aff240847f766a8d154f8af5329c6141b28..c7185660e833927d7147ee9ab13ce2640297ee72 100644 (file)
@@ -71,10 +71,9 @@ static PyObject * load (PyImage * self, PyObject * args)
        short width;
        short height;
        // parse parameters
-       if (!PyArg_ParseTuple(args, "s#hh", &buff, &buffSize, &width, &height))
+       if (!PyArg_ParseTuple(args, "s#hh:load", &buff, &buffSize, &width, &height))
        {
                // report error
-               PyErr_SetString(PyExc_TypeError, "Parameters are not correct");
                return NULL;
        }
        // else check buffer size
index 2418ba254e42ebc341d7d4857ee36cff8d36f8a6..067143e57bbce3a3a8f954f644b0aee64bcf91cb 100644 (file)
@@ -109,7 +109,9 @@ PyObject * getWeight (PyImage * self, PyObject * args)
        short weight = 0;
        // get arguments
        char * id;
-       if (self->m_image != NULL && PyArg_ParseTuple(args, "s", &id))
+       if (!PyArg_ParseTuple(args, "s:getWeight", &id))
+               return NULL;
+       if (self->m_image != NULL)
                // get weight
                weight = getImageMix(self)->getWeight(id);
        // return weight
@@ -123,7 +125,9 @@ PyObject * setWeight (PyImage * self, PyObject * args)
        // get arguments
        char * id;
        short weight = 0;
-       if (self->m_image != NULL && PyArg_ParseTuple(args, "sh", &id, &weight))
+       if (!PyArg_ParseTuple(args, "sh:setWeight", &id, &weight))
+               return NULL;
+       if (self->m_image != NULL)
                // set weight
                if (!getImageMix(self)->setWeight(id, weight))
                {
index a8ece4bc17ecdfdf5252382c29db8da53a895799..51d96d7596ebc11916509889f92edbc5e64eff00 100644 (file)
@@ -51,7 +51,7 @@ http://www.gnu.org/copyleft/lesser.txt.
 
 // macro for exception handling and logging
 #define CATCH_EXCP catch (Exception & exp) \
-{ exp.report(); }
+{ exp.report(); return NULL; }
 
 
 // Blender GameObject type
@@ -280,7 +280,7 @@ PyObject * Texture_refresh (Texture * self, PyObject * args)
 {
        // get parameter - refresh source
        PyObject * param;
-       if (!PyArg_ParseTuple(args, "O", &param) || !PyBool_Check(param))
+       if (!PyArg_ParseTuple(args, "O:refresh", &param) || !PyBool_Check(param))
        {
                // report error
                PyErr_SetString(PyExc_TypeError, "The value must be a bool");
index 08c02628f05694889f1299ad19b5e788a190666d..d509f366910b8a8f209a0f2398fe0ac22909d159 100644 (file)
@@ -1178,7 +1178,7 @@ static int ImageFFmpeg_init (PyObject * pySelf, PyObject * args, PyObject * kwds
        char * file = NULL;
 
        // get parameters
-       if (!PyArg_ParseTuple(args, "s", &file))
+       if (!PyArg_ParseTuple(args, "s:ImageFFmpeg", &file))
                return -1; 
 
        try
@@ -1203,8 +1203,9 @@ static int ImageFFmpeg_init (PyObject * pySelf, PyObject * args, PyObject * kwds
 PyObject * Image_reload (PyImage * self, PyObject *args)
 {
        char * newname = NULL;
-
-       if (self->m_image != NULL && PyArg_ParseTuple(args, "|s", &newname))
+       if (!PyArg_ParseTuple(args, "|s:reload", &newname))
+               return NULL;
+       if (self->m_image != NULL)
        {
                VideoFFmpeg* video = getFFmpeg(self);
                // check type of object
index 239f43763b86ca06fcf4acb10b79197d1b7963c6..1dcc72c8f7d4c92c79060b39d0f7d0a14f70fc69 100644 (file)
@@ -74,7 +74,7 @@ static PyObject * getLastError (PyObject *self, PyObject *args)
 static PyObject * setLogFile (PyObject *self, PyObject *args)
 {
        // get parameters
-       if (!PyArg_ParseTuple(args, "s", &Exception::m_logFile))
+       if (!PyArg_ParseTuple(args, "s:setLogFile", &Exception::m_logFile))
                return Py_BuildValue("i", -1);
        // log file was loaded
        return Py_BuildValue("i", 0);
@@ -86,7 +86,7 @@ static PyObject * imageToArray (PyObject * self, PyObject *args)
 {
        // parameter is Image object
        PyObject * pyImg;
-       if (!PyArg_ParseTuple(args, "O", &pyImg) || !pyImageTypes.in(pyImg->ob_type))
+       if (!PyArg_ParseTuple(args, "O:imageToArray", &pyImg) || !pyImageTypes.in(pyImg->ob_type))
        {
                // if object is incorect, report error
                PyErr_SetString(PyExc_TypeError, "VideoTexture.imageToArray(image): The value must be a image source object");