add id property clear function (matching the same python function for dicts/lists)

This commit is contained in:
Campbell Barton 2013-01-02 23:10:14 +00:00
parent a4a3ed0018
commit 1a7638fa94
5 changed files with 18 additions and 2 deletions

@ -21,7 +21,7 @@
bl_info = {
"name": "Cycles Render Engine",
"author": "",
"blender": (2, 6, 5),
"blender": (2, 60, 5),
"location": "Info header, render engine menu",
"description": "Cycles Render Engine integration",
"warning": "",

@ -315,6 +315,8 @@ __attribute__((nonnull))
* the actual struct IDProperty struct either.*/
void IDP_FreeProperty(struct IDProperty *prop);
void IDP_ClearProperty(IDProperty *prop);
/** Unlinks any struct IDProperty<->ID linkage that might be going on.*/
void IDP_UnlinkProperty(struct IDProperty *prop);

@ -815,6 +815,13 @@ void IDP_FreeProperty(IDProperty *prop)
}
}
void IDP_ClearProperty(IDProperty *prop)
{
IDP_FreeProperty(prop);
prop->data.pointer = NULL;
prop->len = prop->totallen = 0;
}
/* Unlinks any IDProperty<->ID linkage that might be going on.
* note: currently unused.*/
void IDP_UnlinkProperty(IDProperty *prop)

@ -925,7 +925,7 @@ static void set_filter_seq(Scene *scene)
if (seq->type == SEQ_TYPE_MOVIE) {
seq->flag |= SEQ_FILTERY;
reload_sequence_new_file(scene, seq, FALSE);
calc_sequence(scene, seq);
BKE_sequence_calc(scene, seq);
}
}

@ -836,6 +836,11 @@ static PyObject *BPy_IDGroup_to_dict(BPy_IDProperty *self)
return BPy_IDGroup_MapDataToPy(self->prop);
}
static PyObject *BPy_IDGroup_clear(BPy_IDProperty *self)
{
IDP_ClearProperty(self->prop);
Py_RETURN_NONE;
}
/* Matches python dict.get(key, [default]) */
static PyObject *BPy_IDGroup_Get(BPy_IDProperty *self, PyObject *args)
@ -875,6 +880,8 @@ static struct PyMethodDef BPy_IDGroup_methods[] = {
"idprop.get(k[,d]) -> idprop[k] if k in idprop, else d. d defaults to None"},
{"to_dict", (PyCFunction)BPy_IDGroup_to_dict, METH_NOARGS,
"return a purely python version of the group"},
{"clear", (PyCFunction)BPy_IDGroup_clear, METH_NOARGS,
"clear all members from this group"},
{NULL, NULL, 0, NULL}
};