BGE Py api, deleting properties didnt raise an error when the property wasnt there. also added some exception messages and renamed joystick getConnected() to isConnected()

This commit is contained in:
Campbell Barton
2008-09-03 06:43:07 +00:00
parent b818b1a164
commit cfa07e8d2b
4 changed files with 30 additions and 16 deletions

View File

@@ -391,16 +391,23 @@ float CValue::GetPropertyNumber(const STR_String& inName,float defnumber)
bool CValue::RemoveProperty(const STR_String & inName)
{
// Check if there are properties at all which can be removed
if (m_pNamedPropertyArray == NULL)
return false;
CValue* val = GetProperty(inName);
if (NULL != val)
{
val->Release();
m_pNamedPropertyArray->erase(inName);
return true;
}
if (m_pNamedPropertyArray) {
CValue* val = GetProperty(inName);
if (NULL != val)
{
val->Release();
m_pNamedPropertyArray->erase(inName);
return true;
}
}
char err[128];
if (m_pNamedPropertyArray)
sprintf(err, "attribute \"%s\" dosnt exist", inName.ReadPtr());
else
sprintf(err, "attribute \"%s\" dosnt exist (no property array)", inName.ReadPtr());
PyErr_SetString(PyExc_AttributeError, err);
return false;
}
@@ -755,7 +762,8 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj)
int CValue::_delattr(const STR_String& attr)
{
RemoveProperty(attr);
if (!RemoveProperty(attr)) /* sets error */
return 1;
return 0;
}