Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-01-18 23:50:44 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-01-18 23:50:44 +0400
commit57ad3b85d81bb86b24446e9cf23122ce2e9d3fa1 (patch)
tree58799a97fd4cd93660f2b4de4fc797bd58f8283b /source/blender
parent16ffa8e8f432ac2c0909117b48a98cb4b36eaff6 (diff)
fix [#27589] Random crash with python UI
This script was defining an operator within the panels draw function, while its possible to support this its really asking for trouble. the fix is to raise an error when this happens. also fix crash passing non classes to register_class/unregister_class
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/python/intern/bpy_rna.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 4940c53551e..bfb79ea6531 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -7158,8 +7158,25 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
const char *identifier;
PyObject *py_cls_meth;
+ if (!PyType_Check(py_class)) {
+ PyErr_Format(PyExc_ValueError,
+ "register_class(...): "
+ "expected a class argument, not '%.200s'", Py_TYPE(py_class)->tp_name);
+ return NULL;
+ }
+
if (PyDict_GetItem(((PyTypeObject *)py_class)->tp_dict, bpy_intern_str_bl_rna)) {
- PyErr_SetString(PyExc_AttributeError, "register_class(...): already registered as a subclass");
+ PyErr_SetString(PyExc_ValueError,
+ "register_class(...): "
+ "already registered as a subclass");
+ return NULL;
+ }
+
+ if (!pyrna_write_check()) {
+ PyErr_Format(PyExc_RuntimeError,
+ "register_class(...): "
+ "can't run in readonly state '%.200s'",
+ ((PyTypeObject *)py_class)->tp_name);
return NULL;
}
@@ -7284,12 +7301,27 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
StructRNA *srna;
PyObject *py_cls_meth;
+ if (!PyType_Check(py_class)) {
+ PyErr_Format(PyExc_ValueError,
+ "register_class(...): "
+ "expected a class argument, not '%.200s'", Py_TYPE(py_class)->tp_name);
+ return NULL;
+ }
+
/*if (PyDict_GetItem(((PyTypeObject *)py_class)->tp_dict, bpy_intern_str_bl_rna) == NULL) {
PWM_cursor_wait(0);
PyErr_SetString(PyExc_ValueError, "unregister_class(): not a registered as a subclass");
return NULL;
}*/
+ if (!pyrna_write_check()) {
+ PyErr_Format(PyExc_RuntimeError,
+ "unregister_class(...): "
+ "can't run in readonly state '%.200s'",
+ ((PyTypeObject *)py_class)->tp_name);
+ return NULL;
+ }
+
srna = pyrna_struct_as_srna(py_class, 0, "unregister_class(...):");
if (srna == NULL)
return NULL;