Cleanup: use variable instead of define
This commit is contained in:
@@ -47,9 +47,9 @@
|
||||
|
||||
#include "../generic/python_utildefines.h"
|
||||
|
||||
/* use this to stop other capsules from being mis-used */
|
||||
#define RNA_CAPSULE_ID "RNA_HANDLE"
|
||||
#define RNA_CAPSULE_ID_INVALID "RNA_HANDLE_REMOVED"
|
||||
/* Use this to stop other capsules from being mis-used. */
|
||||
static const char *rna_capsual_id = "RNA_HANDLE";
|
||||
static const char *rna_capsual_id_invalid = "RNA_HANDLE_REMOVED";
|
||||
|
||||
static const EnumPropertyItem region_draw_mode_items[] = {
|
||||
{REGION_DRAW_POST_PIXEL, "POST_PIXEL", 0, "Post Pixel", ""},
|
||||
@@ -165,7 +165,7 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PyCapsule_New((void *)handle, RNA_CAPSULE_ID, NULL);
|
||||
return PyCapsule_New((void *)handle, rna_capsual_id, NULL);
|
||||
}
|
||||
|
||||
PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args)
|
||||
@@ -177,7 +177,7 @@ PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "O!:callback_remove", &PyCapsule_Type, &py_handle))
|
||||
return NULL;
|
||||
|
||||
handle = PyCapsule_GetPointer(py_handle, RNA_CAPSULE_ID);
|
||||
handle = PyCapsule_GetPointer(py_handle, rna_capsual_id);
|
||||
|
||||
if (handle == NULL) {
|
||||
PyErr_SetString(PyExc_ValueError, "callback_remove(handle): NULL handle given, invalid or already removed");
|
||||
@@ -196,7 +196,7 @@ PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args)
|
||||
}
|
||||
|
||||
/* don't allow reuse */
|
||||
PyCapsule_SetName(py_handle, RNA_CAPSULE_ID_INVALID);
|
||||
PyCapsule_SetName(py_handle, rna_capsual_id_invalid);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
@@ -343,7 +343,7 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyObject *ret = PyCapsule_New((void *)handle, RNA_CAPSULE_ID, NULL);
|
||||
PyObject *ret = PyCapsule_New((void *)handle, rna_capsual_id, NULL);
|
||||
|
||||
/* Store 'args' in context as well as the handler custom-data,
|
||||
* because the handle may be freed by Blender (new file, new window... etc) */
|
||||
@@ -371,7 +371,7 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
|
||||
return NULL;
|
||||
}
|
||||
py_handle = PyTuple_GET_ITEM(args, 1);
|
||||
handle = PyCapsule_GetPointer(py_handle, RNA_CAPSULE_ID);
|
||||
handle = PyCapsule_GetPointer(py_handle, rna_capsual_id);
|
||||
if (handle == NULL) {
|
||||
PyErr_SetString(PyExc_ValueError, "callback_remove(handler): NULL handler given, invalid or already removed");
|
||||
return NULL;
|
||||
@@ -438,7 +438,7 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
|
||||
/* don't allow reuse */
|
||||
if (capsule_clear) {
|
||||
Py_DECREF(handle_args);
|
||||
PyCapsule_SetName(py_handle, RNA_CAPSULE_ID_INVALID);
|
||||
PyCapsule_SetName(py_handle, rna_capsual_id_invalid);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
|
Reference in New Issue
Block a user