Python: Raise an error even NO_MAIN data is assigned to object

The goal is to prevent assignment of temporary or evaluated meshes
to objects from the main database.

Majority of the change is actually related on passing reports around.

On a positive side there are more error prints which can become more
visible to scripters.

There are still possible further improvements in the related areas.
For example, disable user counting for evaluated ID datablocks when
assignment happens. But can also happen later on as a separate
improvement.

Reviewers: brecht, campbellbarton, mont29

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D4884
This commit is contained in:
2019-05-17 13:59:59 +02:00
parent 8b5816e76b
commit 34d67601b7
50 changed files with 319 additions and 127 deletions

View File

@@ -2029,7 +2029,15 @@ static int pyrna_py_to_prop(
else {
/* data == NULL, assign to RNA */
if (value == Py_None || RNA_struct_is_a(param->ptr.type, ptr_type)) {
RNA_property_pointer_set(ptr, prop, value == Py_None ? PointerRNA_NULL : param->ptr);
ReportList reports;
BKE_reports_init(&reports, RPT_STORE);
RNA_property_pointer_set(
&reports, ptr, prop, value == Py_None ? PointerRNA_NULL : param->ptr);
int err = (BPy_reports_to_error(&reports, PyExc_RuntimeError, true));
if (err == -1) {
Py_XDECREF(value_new);
return -1;
}
}
else {
raise_error = true;