Bug fixed in sf.String

Code clean up


git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1037 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
remi-k 2009-03-02 19:00:41 +00:00
parent e28a89f902
commit 870d049bc8
4 changed files with 22 additions and 14 deletions

View File

@ -234,14 +234,9 @@ class Main:
while self.win.GetEvent(event): # Event Handler
if event.Type == sf.Event.Closed:
self.win.Close()
elif event.Type == sf.Event.KeyPressed:
for key in self.keys:
if event.Key.Code == key:
self.keys[key](True)
elif event.Type == sf.Event.KeyReleased:
for key in self.keys:
if event.Key.Code == key:
self.keys[key](False)
elif event.Type == sf.Event.KeyPressed or event.Type == sf.Event.KeyReleased:
if event.Key.Code in self.keys:
self.keys[event.Key.Code](event.Type == sf.Event.KeyPressed)
self.win.Display()
self.win.Clear(background_color)
self.next_frame(self.win)

View File

@ -63,7 +63,7 @@ PySfFont_LoadFromFile(PySfFont* self, PyObject *args, PyObject *kwds)
int Length;
bool result;
std::string Encoding;
if (PyArg_ParseTupleAndKeywords(args, kwds, "s|I:Font.LoadFromFile", (char **)kwlist, &Filename, &Charsize))
if (PyArg_ParseTuple(args, "s|I:Font.LoadFromFile", &Filename, &Charsize))
result = self->obj->LoadFromFile(Filename, Charsize);
else if (PyArg_ParseTupleAndKeywords(args, kwds, "s|Iu:Font.LoadFromFile", (char **)kwlist, &Filename, &Charsize, &Charset))
{
@ -113,7 +113,7 @@ PySfFont_LoadFromMemory(PySfFont* self, PyObject *args, PyObject *kwds)
int Length;
bool result;
std::string Encoding;
if (PyArg_ParseTupleAndKeywords(args, kwds, "s#|I:Font.LoadFromMemory", (char **)kwlist, &Data, &Size, &Charsize))
if (PyArg_ParseTuple(args, "s#|I:Font.LoadFromMemory", &Data, &Size, &Charsize))
result = self->obj->LoadFromMemory(Data, Size, Charsize);
else if (PyArg_ParseTupleAndKeywords(args, kwds, "s#|Iu:Font.LoadFromMemory", (char **)kwlist, &Data, &Size, &Charsize, &Charset))
{

View File

@ -38,19 +38,22 @@ bool CustomSoundStream::OnStart()
Py_DECREF(OnStart);
Py_DECREF(Result);
}
if (PyErr_Occurred())
{
PyErr_Print();
return false;
}
return result;
}
bool CustomSoundStream::OnGetData(Chunk& Data)
{
bool result = false;
if (PyData != NULL) {
Py_DECREF(PyData);
}
Py_XDECREF(PyData);
PyData = NULL;
if (PyObject_HasAttrString(SoundStream, "OnGetData"))
{
PyObject *Function = PyObject_GetAttrString(SoundStream, "OnGetData");
Data.NbSamples = 0;
PyData = PyObject_CallFunction(Function, NULL);
if (PyData != NULL)
{
@ -63,6 +66,13 @@ bool CustomSoundStream::OnGetData(Chunk& Data)
}
Py_DECREF(Function);
}
if (PyErr_Occurred())
{
PyErr_Print();
Py_XDECREF(PyData);
PyData = NULL;
return false;
}
return result;
}

View File

@ -144,7 +144,10 @@ PySfString_SetFont(PySfString* self, PyObject *args)
{
PySfFont *Font = (PySfFont *)args;
if (!PyObject_TypeCheck(Font, &PySfFontType))
{
PyErr_SetString(PyExc_ValueError, "String.SetFont() Argument must be a sf.Font");
return NULL;
}
self->obj->SetFont(*(Font->obj));
Py_RETURN_NONE;
}