[Bf-blender-cvs] [3887c0f] particles_refactor: Fix for particle getattro: Throw an exception if iterator is not valid, otherwise expect to find a correct void *data (assert is used to as a sanity check, should never fail).
Lukas Tönne
noreply at git.blender.org
Tue Apr 22 12:06:24 CEST 2014
Commit: 3887c0f2f14b6e2c135653efdd3641559d91c086
Author: Lukas Tönne
Date: Sat Dec 21 10:22:52 2013 +0100
https://developer.blender.org/rB3887c0f2f14b6e2c135653efdd3641559d91c086
Fix for particle getattro: Throw an exception if iterator is not valid,
otherwise expect to find a correct void *data (assert is used to as a
sanity check, should never fail).
===================================================================
M source/blender/python/bparticles/bparticles_py_types.c
===================================================================
diff --git a/source/blender/python/bparticles/bparticles_py_types.c b/source/blender/python/bparticles/bparticles_py_types.c
index 8920e70..a9f2032 100644
--- a/source/blender/python/bparticles/bparticles_py_types.c
+++ b/source/blender/python/bparticles/bparticles_py_types.c
@@ -541,11 +541,12 @@ static PyObject *bpy_bpar_particle_getattro(BPy_NParticleParticle *self, PyObjec
// PYRNA_STRUCT_CHECK_OBJ(self);
- if (!BKE_nparticle_iter_valid(&self->iter)) {
+ if (name == NULL) {
+ PyErr_SetString(PyExc_AttributeError, "NParticleParticle: __getattr__ must be a string");
ret = NULL;
}
- else if (name == NULL) {
- PyErr_SetString(PyExc_AttributeError, "NParticleParticle: __getattr__ must be a string");
+ else if (!BKE_nparticle_iter_valid(&self->iter)) {
+ PyErr_Format(PyExc_AttributeError, "NParticleParticle: particle %d does not exist", self->id);
ret = NULL;
}
else {
@@ -558,12 +559,8 @@ static PyObject *bpy_bpar_particle_getattro(BPy_NParticleParticle *self, PyObjec
}
else {
data = BKE_nparticle_attribute_state_data(attrstate, self->iter.index);
- if (!data) {
- ret = NULL;
- }
- else {
- ret = bpy_bpar_particle_data_read(&attrstate->desc, data);
- }
+ BLI_assert(data != NULL); /* the iterator is valid, so this should never happen */
+ ret = bpy_bpar_particle_data_read(&attrstate->desc, data);
}
}
More information about the Bf-blender-cvs
mailing list