Python: Raise an error even NO_MAIN data is assigned to object
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 17 May 2019 11:59:59 +0000 (13:59 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 17 May 2019 12:27:13 +0000 (14:27 +0200)
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

50 files changed:
source/blender/blenkernel/intern/library.c
source/blender/editors/curve/editfont.c
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_eyedropper_datablock.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/io/io_cache.c
source/blender/editors/render/render_shading.c
source/blender/editors/sound/sound_ops.c
source/blender/editors/space_action/action_data.c
source/blender/editors/space_clip/clip_ops.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_node/node_add.c
source/blender/editors/space_text/text_ops.c
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_action.c
source/blender/makesrna/intern/rna_animation.c
source/blender/makesrna/intern/rna_armature.c
source/blender/makesrna/intern/rna_cloth.c
source/blender/makesrna/intern/rna_constraint.c
source/blender/makesrna/intern/rna_curve.c
source/blender/makesrna/intern/rna_fcurve.c
source/blender/makesrna/intern/rna_gpencil.c
source/blender/makesrna/intern/rna_gpencil_modifier.c
source/blender/makesrna/intern/rna_image.c
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_internal_types.h
source/blender/makesrna/intern/rna_key.c
source/blender/makesrna/intern/rna_layer.c
source/blender/makesrna/intern/rna_linestyle.c
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_mask.c
source/blender/makesrna/intern/rna_material.c
source/blender/makesrna/intern/rna_mesh_utils.h
source/blender/makesrna/intern/rna_modifier.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_palette.c
source/blender/makesrna/intern/rna_particle.c
source/blender/makesrna/intern/rna_pose.c
source/blender/makesrna/intern/rna_rna.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_sequencer.c
source/blender/makesrna/intern/rna_shader_fx.c
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_tracking.c
source/blender/makesrna/intern/rna_wm.c
source/blender/python/intern/bpy_rna.c

index 3e6f93d..7fb6f78 100644 (file)
@@ -873,7 +873,7 @@ bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
 
         /* assign copy */
         RNA_id_pointer_create(newid, &idptr);
-        RNA_property_pointer_set(ptr, prop, idptr);
+        RNA_property_pointer_set(NULL, ptr, prop, idptr);
         RNA_property_update(C, ptr, prop);
 
         /* tag grease pencil datablock and disable onion */
index d1b1f43..0759b64 100644 (file)
@@ -2007,7 +2007,7 @@ static int font_open_exec(bContext *C, wmOperator *op)
     id_us_min(&font->id);
 
     RNA_id_pointer_create(&font->id, &idptr);
-    RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr);
+    RNA_property_pointer_set(NULL, &pprop->ptr, pprop->prop, idptr);
     RNA_property_update(C, &pprop->ptr, pprop->prop);
   }
 
@@ -2090,7 +2090,7 @@ static int font_unlink_exec(bContext *C, wmOperator *op)
   builtin_font = BKE_vfont_builtin_get();
 
   RNA_id_pointer_create(&builtin_font->id, &idptr);
-  RNA_property_pointer_set(&pprop.ptr, pprop.prop, idptr);
+  RNA_property_pointer_set(NULL, &pprop.ptr, pprop.prop, idptr);
   RNA_property_update(C, &pprop.ptr, pprop.prop);
 
   return OPERATOR_FINISHED;
index 0e4b07f..f1724d9 100644 (file)
@@ -2772,7 +2772,7 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
       }
       else if (type == PROP_POINTER) {
         if (str[0] == '\0') {
-          RNA_property_pointer_set(&but->rnapoin, but->rnaprop, PointerRNA_NULL);
+          RNA_property_pointer_set(NULL, &but->rnapoin, but->rnaprop, PointerRNA_NULL);
           return true;
         }
         else {
@@ -2788,14 +2788,14 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
            * Fact remains, using editstr as main 'reference' over whole search button thingy
            * is utterly weak and should be redesigned imho, but that's not a simple task. */
           if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr)) {
-            RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr);
+            RNA_property_pointer_set(NULL, &but->rnapoin, but->rnaprop, rptr);
           }
           else if (but->func_arg2 != NULL) {
             RNA_pointer_create(NULL,
                                RNA_property_pointer_type(&but->rnapoin, but->rnaprop),
                                but->func_arg2,
                                &rptr);
-            RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr);
+            RNA_property_pointer_set(NULL, &but->rnapoin, but->rnaprop, rptr);
           }
 
           return true;
index 1d90139..4a2d59c 100644 (file)
@@ -207,7 +207,7 @@ static bool datadropper_id_set(bContext *C, DataDropper *ddr, ID *id)
 
   RNA_id_pointer_create(id, &ptr_value);
 
-  RNA_property_pointer_set(&ddr->ptr, ddr->prop, ptr_value);
+  RNA_property_pointer_set(NULL, &ddr->ptr, ddr->prop, ptr_value);
 
   RNA_property_update(C, &ddr->ptr, ddr->prop);
 
index e4adf75..a3b438e 100644 (file)
@@ -1744,7 +1744,7 @@ static void ui_selectcontext_apply(bContext *C,
       }
       else if (rna_type == PROP_POINTER) {
         const PointerRNA other_value = delta.p;
-        RNA_property_pointer_set(&lptr, lprop, other_value);
+        RNA_property_pointer_set(NULL, &lptr, lprop, other_value);
       }
 
       RNA_property_update(C, &lptr, prop);
index 9e91505..3dbfd3d 100644 (file)
@@ -298,7 +298,7 @@ static void template_ID_set_property_cb(bContext *C, void *arg_template, void *i
     PointerRNA idptr;
 
     RNA_id_pointer_create(item, &idptr);
-    RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr);
+    RNA_property_pointer_set(NULL, &template_ui->ptr, template_ui->prop, idptr);
     RNA_property_update(C, &template_ui->ptr, template_ui->prop);
   }
 }
@@ -489,7 +489,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
       break;
     case UI_ID_DELETE:
       memset(&idptr, 0, sizeof(idptr));
-      RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr);
+      RNA_property_pointer_set(NULL, &template_ui->ptr, template_ui->prop, idptr);
       RNA_property_update(C, &template_ui->ptr, template_ui->prop);
 
       if (id && CTX_wm_window(C)->eventstate->shift) {
@@ -532,7 +532,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
             idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop);
           }
         }
-        RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr);
+        RNA_property_pointer_set(NULL, &template_ui->ptr, template_ui->prop, idptr);
         RNA_property_update(C, &template_ui->ptr, template_ui->prop);
       }
       break;
@@ -541,7 +541,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
         BKE_override_static_free(&id->override_static);
         /* reassign to get get proper updates/notifiers */
         idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop);
-        RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr);
+        RNA_property_pointer_set(NULL, &template_ui->ptr, template_ui->prop, idptr);
         RNA_property_update(C, &template_ui->ptr, template_ui->prop);
       }
       break;
@@ -1455,7 +1455,7 @@ static void template_search_handle_cb(bContext *C, void *arg_template, void *ite
   PointerRNA item_ptr;
 
   RNA_pointer_create(NULL, type, item, &item_ptr);
-  RNA_property_pointer_set(&coll_search->target_ptr, coll_search->target_prop, item_ptr);
+  RNA_property_pointer_set(NULL, &coll_search->target_ptr, coll_search->target_prop, item_ptr);
   RNA_property_update(C, &coll_search->target_ptr, coll_search->target_prop);
 }
 
index 3dd3b20..e2b3b6a 100644 (file)
@@ -108,7 +108,7 @@ static int cachefile_open_exec(bContext *C, wmOperator *op)
 
       PointerRNA idptr;
       RNA_id_pointer_create(&cache_file->id, &idptr);
-      RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr);
+      RNA_property_pointer_set(NULL, &pprop->ptr, pprop->prop, idptr);
       RNA_property_update(C, &pprop->ptr, pprop->prop);
     }
 
index 3186f01..8819b7a 100644 (file)
@@ -595,7 +595,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
     id_us_min(&ma->id);
 
     RNA_id_pointer_create(&ma->id, &idptr);
-    RNA_property_pointer_set(&ptr, prop, idptr);
+    RNA_property_pointer_set(NULL, &ptr, prop, idptr);
     RNA_property_update(C, &ptr, prop);
   }
 
@@ -644,7 +644,7 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op))
     id_us_min(&tex->id);
 
     RNA_id_pointer_create(&tex->id, &idptr);
-    RNA_property_pointer_set(&ptr, prop, idptr);
+    RNA_property_pointer_set(NULL, &ptr, prop, idptr);
     RNA_property_update(C, &ptr, prop);
   }
 
@@ -695,7 +695,7 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
     id_us_min(&wo->id);
 
     RNA_id_pointer_create(&wo->id, &idptr);
-    RNA_property_pointer_set(&ptr, prop, idptr);
+    RNA_property_pointer_set(NULL, &ptr, prop, idptr);
     RNA_property_update(C, &ptr, prop);
   }
 
index 25c05e2..692681c 100644 (file)
@@ -136,7 +136,7 @@ static int sound_open_exec(bContext *C, wmOperator *op)
     id_us_min(&sound->id);
 
     RNA_id_pointer_create(&sound->id, &idptr);
-    RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr);
+    RNA_property_pointer_set(NULL, &pprop->ptr, pprop->prop, idptr);
     RNA_property_update(C, &pprop->ptr, pprop->prop);
   }
 
index db50427..d3e5c01 100644 (file)
@@ -155,7 +155,7 @@ static void actedit_change_action(bContext *C, bAction *act)
   RNA_id_pointer_create((ID *)act, &idptr);
 
   /* set the new pointer, and force a refresh */
-  RNA_property_pointer_set(&ptr, prop, idptr);
+  RNA_property_pointer_set(NULL, &ptr, prop, idptr);
   RNA_property_update(C, &ptr, prop);
 }
 
@@ -261,7 +261,7 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op))
      * NOTE: we can't use actedit_change_action, as this function is also called from the NLA
      */
     RNA_id_pointer_create(&action->id, &idptr);
-    RNA_property_pointer_set(&ptr, prop, idptr);
+    RNA_property_pointer_set(NULL, &ptr, prop, idptr);
     RNA_property_update(C, &ptr, prop);
   }
 
@@ -619,7 +619,7 @@ void ED_animedit_unlink_action(
       prop = RNA_struct_find_property(&ptr, "action");
 
       /* clear... */
-      RNA_property_pointer_set(&ptr, prop, PointerRNA_NULL);
+      RNA_property_pointer_set(NULL, &ptr, prop, PointerRNA_NULL);
       RNA_property_update(C, &ptr, prop);
     }
   }
index a6b1db1..e5698ed 100644 (file)
@@ -245,7 +245,7 @@ static int open_exec(bContext *C, wmOperator *op)
     id_us_min(&clip->id);
 
     RNA_id_pointer_create(&clip->id, &idptr);
-    RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr);
+    RNA_property_pointer_set(NULL, &pprop->ptr, pprop->prop, idptr);
     RNA_property_update(C, &pprop->ptr, pprop->prop);
   }
   else if (sc) {
index a25ba6f..b49fd92 100644 (file)
@@ -1339,7 +1339,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
 
     PointerRNA imaptr;
     RNA_id_pointer_create(&ima->id, &imaptr);
-    RNA_property_pointer_set(&iod->pprop.ptr, iod->pprop.prop, imaptr);
+    RNA_property_pointer_set(NULL, &iod->pprop.ptr, iod->pprop.prop, imaptr);
     RNA_property_update(C, &iod->pprop.ptr, iod->pprop.prop);
   }
 
@@ -2426,7 +2426,7 @@ static int image_new_exec(bContext *C, wmOperator *op)
 
     PointerRNA imaptr;
     RNA_id_pointer_create(&ima->id, &imaptr);
-    RNA_property_pointer_set(&data->pprop.ptr, data->pprop.prop, imaptr);
+    RNA_property_pointer_set(NULL, &data->pprop.ptr, data->pprop.prop, imaptr);
     RNA_property_update(C, &data->pprop.ptr, data->pprop.prop);
   }
   else if (sima) {
index 714ed70..e677c64 100644 (file)
@@ -521,7 +521,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op)
     id_us_min(&ntree->id);
 
     RNA_id_pointer_create(&ntree->id, &idptr);
-    RNA_property_pointer_set(&ptr, prop, idptr);
+    RNA_property_pointer_set(NULL, &ptr, prop, idptr);
     RNA_property_update(C, &ptr, prop);
   }
   else if (snode) {
index a3a438c..a9dd2a5 100644 (file)
@@ -247,7 +247,7 @@ static int text_new_exec(bContext *C, wmOperator *UNUSED(op))
 
   if (prop) {
     RNA_id_pointer_create(&text->id, &idptr);
-    RNA_property_pointer_set(&ptr, prop, idptr);
+    RNA_property_pointer_set(NULL, &ptr, prop, idptr);
     RNA_property_update(C, &ptr, prop);
   }
   else if (st) {
@@ -326,7 +326,7 @@ static int text_open_exec(bContext *C, wmOperator *op)
 
   if (pprop->prop) {
     RNA_id_pointer_create(&text->id, &idptr);
-    RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr);
+    RNA_property_pointer_set(NULL, &pprop->ptr, pprop->prop, idptr);
     RNA_property_update(C, &pprop->ptr, pprop->prop);
   }
   else if (st) {
index a7b111d..5aee34d 100644 (file)
@@ -1031,7 +1031,10 @@ int RNA_property_enum_step(
     const struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, int from_value, int step);
 
 PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop);
-void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value);
+void RNA_property_pointer_set(struct ReportList *reports,
+                              PointerRNA *ptr,
+                              PropertyRNA *prop,
+                              PointerRNA ptr_value);
 PointerRNA RNA_property_pointer_get_default(PointerRNA *ptr, PropertyRNA *prop);
 
 void RNA_property_collection_begin(PointerRNA *ptr,
index 83c115a..a77402c 100644 (file)
@@ -1033,10 +1033,10 @@ static char *rna_def_property_set_func(
       break;
     }
     case PROP_POINTER: {
-      fprintf(f, "void %s(PointerRNA *ptr, PointerRNA value)\n", func);
+      fprintf(f, "void %s(struct ReportList *reports, PointerRNA *ptr, PointerRNA value)\n", func);
       fprintf(f, "{\n");
       if (manualfunc) {
-        fprintf(f, "    %s(ptr, value);\n", manualfunc);
+        fprintf(f, "    %s(reports, ptr, value);\n", manualfunc);
       }
       else {
         rna_print_data_get(f, dp);
index a12951d..b56a031 100644 (file)
@@ -3733,24 +3733,29 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
   }
 }
 
-void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value)
+void RNA_property_pointer_set(ReportList *reports,
+                              PointerRNA *ptr,
+                              PropertyRNA *prop,
+                              PointerRNA ptr_value)
 {
   PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop;
   BLI_assert(RNA_property_type(prop) == PROP_POINTER);
 
   /* Check types */
   if (ptr_value.type != NULL && !RNA_struct_is_a(ptr_value.type, pprop->type)) {
-    printf("%s: expected %s type, not %s.\n",
-           __func__,
-           pprop->type->identifier,
-           ptr_value.type->identifier);
+    BKE_reportf(reports,
+                RPT_ERROR,
+                "%s: expected %s type, not %s.\n",
+                __func__,
+                pprop->type->identifier,
+                ptr_value.type->identifier);
     return;
   }
 
   /* RNA */
   if (pprop->set && !((prop->flag & PROP_NEVER_NULL) && ptr_value.data == NULL) &&
       !((prop->flag & PROP_ID_SELF_CHECK) && ptr->id.data == ptr_value.id.data)) {
-    pprop->set(ptr, ptr_value);
+    pprop->set(reports, ptr, ptr_value);
   }
   /* IDProperty */
   else if (prop->flag & PROP_EDITABLE) {
@@ -6422,7 +6427,7 @@ void RNA_pointer_set(PointerRNA *ptr, const char *name, PointerRNA ptr_value)
   PropertyRNA *prop = RNA_struct_find_property(ptr, name);
 
   if (prop) {
-    RNA_property_pointer_set(ptr, prop, ptr_value);
+    RNA_property_pointer_set(NULL, ptr, prop, ptr_value);
   }
   else {
     printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
@@ -7971,7 +7976,7 @@ bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
 
     case PROP_POINTER: {
       PointerRNA value = RNA_property_pointer_get_default(ptr, prop);
-      RNA_property_pointer_set(ptr, prop, value);
+      RNA_property_pointer_set(NULL, ptr, prop, value);
       return true;
     }
 
index bb3585d..e99a1ff 100644 (file)
@@ -214,7 +214,9 @@ static PointerRNA rna_Action_active_pose_marker_get(PointerRNA *ptr)
       ptr, &RNA_TimelineMarker, BLI_findlink(&act->markers, act->active_marker - 1));
 }
 
-static void rna_Action_active_pose_marker_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Action_active_pose_marker_set(struct ReportList *UNUSED(reports),
+                                              PointerRNA *ptr,
+                                              PointerRNA value)
 {
   bAction *act = (bAction *)ptr->data;
   act->active_marker = BLI_findindex(&act->markers, value.data) + 1;
index 6a5bae2..ba79295 100644 (file)
@@ -151,7 +151,9 @@ static int rna_AnimData_action_editable(PointerRNA *ptr, const char **UNUSED(r_i
     return PROP_EDITABLE;
 }
 
-static void rna_AnimData_action_set(PointerRNA *ptr, PointerRNA value)
+static void rna_AnimData_action_set(struct ReportList *UNUSED(reports),
+                                    PointerRNA *ptr,
+                                    PointerRNA value)
 {
   ID *ownerId = (ID *)ptr->id.data;
 
@@ -461,7 +463,9 @@ static PointerRNA rna_KeyingSet_active_ksPath_get(PointerRNA *ptr)
       ptr, &RNA_KeyingSetPath, BLI_findlink(&ks->paths, ks->active_path - 1));
 }
 
-static void rna_KeyingSet_active_ksPath_set(PointerRNA *ptr, PointerRNA value)
+static void rna_KeyingSet_active_ksPath_set(struct ReportList *UNUSED(reports),
+                                            PointerRNA *ptr,
+                                            PointerRNA value)
 {
   KeyingSet *ks = (KeyingSet *)ptr->data;
   KS_Path *ksp = (KS_Path *)value.data;
@@ -612,7 +616,9 @@ static PointerRNA rna_NlaTrack_active_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_NlaTrack, track);
 }
 
-static void rna_NlaTrack_active_set(PointerRNA *ptr, PointerRNA value)
+static void rna_NlaTrack_active_set(struct ReportList *UNUSED(reports),
+                                    PointerRNA *ptr,
+                                    PointerRNA value)
 {
   AnimData *adt = (AnimData *)ptr->data;
   NlaTrack *track = (NlaTrack *)value.data;
index 0eec597..3aef22f 100644 (file)
@@ -67,7 +67,9 @@ static void rna_Armature_dependency_update(Main *bmain, Scene *UNUSED(scene), Po
   WM_main_add_notifier(NC_GEOM | ND_DATA, id);
 }
 
-static void rna_Armature_act_bone_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Armature_act_bone_set(struct ReportList *UNUSED(reports),
+                                      PointerRNA *ptr,
+                                      PointerRNA value)
 {
   bArmature *arm = (bArmature *)ptr->data;
 
@@ -89,7 +91,9 @@ static void rna_Armature_act_bone_set(PointerRNA *ptr, PointerRNA value)
   }
 }
 
-static void rna_Armature_act_edit_bone_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Armature_act_edit_bone_set(struct ReportList *UNUSED(reports),
+                                           PointerRNA *ptr,
+                                           PointerRNA value)
 {
   bArmature *arm = (bArmature *)ptr->data;
 
@@ -395,7 +399,9 @@ static PointerRNA rna_EditBone_parent_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_EditBone, data->parent);
 }
 
-static void rna_EditBone_parent_set(PointerRNA *ptr, PointerRNA value)
+static void rna_EditBone_parent_set(struct ReportList *UNUSED(reports),
+                                    PointerRNA *ptr,
+                                    PointerRNA value)
 {
   EditBone *ebone = (EditBone *)(ptr->data);
   EditBone *pbone, *parbone = (EditBone *)value.data;
@@ -463,7 +469,9 @@ static PointerRNA rna_EditBone_bbone_prev_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_EditBone, data->bbone_prev);
 }
 
-static void rna_EditBone_bbone_prev_set(PointerRNA *ptr, PointerRNA value)
+static void rna_EditBone_bbone_prev_set(struct ReportList *UNUSED(reports),
+                                        PointerRNA *ptr,
+                                        PointerRNA value)
 {
   EditBone *ebone = (EditBone *)(ptr->data);
   EditBone *hbone = (EditBone *)value.data;
@@ -474,7 +482,9 @@ static void rna_EditBone_bbone_prev_set(PointerRNA *ptr, PointerRNA value)
   }
 }
 
-static void rna_Bone_bbone_prev_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Bone_bbone_prev_set(struct ReportList *UNUSED(reports),
+                                    PointerRNA *ptr,
+                                    PointerRNA value)
 {
   Bone *bone = (Bone *)ptr->data;
   Bone *hbone = (Bone *)value.data;
@@ -491,7 +501,9 @@ static PointerRNA rna_EditBone_bbone_next_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_EditBone, data->bbone_next);
 }
 
-static void rna_EditBone_bbone_next_set(PointerRNA *ptr, PointerRNA value)
+static void rna_EditBone_bbone_next_set(struct ReportList *UNUSED(reports),
+                                        PointerRNA *ptr,
+                                        PointerRNA value)
 {
   EditBone *ebone = (EditBone *)(ptr->data);
   EditBone *hbone = (EditBone *)value.data;
@@ -502,7 +514,9 @@ static void rna_EditBone_bbone_next_set(PointerRNA *ptr, PointerRNA value)
   }
 }
 
-static void rna_Bone_bbone_next_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Bone_bbone_next_set(struct ReportList *UNUSED(reports),
+                                    PointerRNA *ptr,
+                                    PointerRNA value)
 {
   Bone *bone = (Bone *)ptr->data;
   Bone *hbone = (Bone *)value.data;
index 1606343..bab7075 100644 (file)
@@ -306,7 +306,9 @@ static PointerRNA rna_ClothSettings_rest_shape_key_get(PointerRNA *ptr)
   return rna_object_shapekey_index_get(ob->data, sim->shapekey_rest);
 }
 
-static void rna_ClothSettings_rest_shape_key_set(PointerRNA *ptr, PointerRNA value)
+static void rna_ClothSettings_rest_shape_key_set(struct ReportList *UNUSED(reports),
+                                                 PointerRNA *ptr,
+                                                 PointerRNA value)
 {
   Object *ob = (Object *)ptr->id.data;
   ClothSimSettings *sim = (ClothSimSettings *)ptr->data;
index 41ad94f..252dc40 100644 (file)
@@ -351,7 +351,9 @@ static StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr)
   }
 }
 
-static void rna_ConstraintTargetBone_target_set(PointerRNA *ptr, PointerRNA value)
+static void rna_ConstraintTargetBone_target_set(struct ReportList *UNUSED(reports),
+                                                PointerRNA *ptr,
+                                                PointerRNA value)
 {
   bConstraintTarget *tgt = (bConstraintTarget *)ptr->data;
   Object *ob = value.data;
@@ -665,7 +667,9 @@ static bool rna_Constraint_cameraObject_poll(PointerRNA *ptr, PointerRNA value)
   return 0;
 }
 
-static void rna_Constraint_followTrack_camera_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Constraint_followTrack_camera_set(struct ReportList *UNUSED(reports),
+                                                  PointerRNA *ptr,
+                                                  PointerRNA value)
 {
   bConstraint *con = (bConstraint *)ptr->data;
   bFollowTrackConstraint *data = (bFollowTrackConstraint *)con->data;
@@ -682,7 +686,9 @@ static void rna_Constraint_followTrack_camera_set(PointerRNA *ptr, PointerRNA va
   }
 }
 
-static void rna_Constraint_followTrack_depthObject_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Constraint_followTrack_depthObject_set(struct ReportList *UNUSED(reports),
+                                                       PointerRNA *ptr,
+                                                       PointerRNA value)
 {
   bConstraint *con = (bConstraint *)ptr->data;
   bFollowTrackConstraint *data = (bFollowTrackConstraint *)con->data;
@@ -712,7 +718,9 @@ static bool rna_Constraint_followTrack_depthObject_poll(PointerRNA *ptr, Pointer
   return 0;
 }
 
-static void rna_Constraint_objectSolver_camera_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Constraint_objectSolver_camera_set(struct ReportList *UNUSED(reports),
+                                                   PointerRNA *ptr,
+                                                   PointerRNA value)
 {
   bConstraint *con = (bConstraint *)ptr->data;
   bObjectSolverConstraint *data = (bObjectSolverConstraint *)con->data;
index 9c7ad60..111e895 100644 (file)
@@ -438,7 +438,9 @@ static PointerRNA rna_Curve_bevelObject_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, NULL, NULL);
 }
 
-static void rna_Curve_bevelObject_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Curve_bevelObject_set(struct ReportList *UNUSED(reports),
+                                      PointerRNA *ptr,
+                                      PointerRNA value)
 {
   Curve *cu = (Curve *)ptr->id.data;
   Object *ob = (Object *)value.data;
@@ -481,7 +483,9 @@ static PointerRNA rna_Curve_taperObject_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, NULL, NULL);
 }
 
-static void rna_Curve_taperObject_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Curve_taperObject_set(struct ReportList *UNUSED(reports),
+                                      PointerRNA *ptr,
+                                      PointerRNA value)
 {
   Curve *cu = (Curve *)ptr->id.data;
   Object *ob = (Object *)value.data;
@@ -730,7 +734,9 @@ static PointerRNA rna_Curve_active_spline_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, NULL, NULL);
 }
 
-static void rna_Curve_active_spline_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Curve_active_spline_set(struct ReportList *UNUSED(reports),
+                                        PointerRNA *ptr,
+                                        PointerRNA value)
 {
   Curve *cu = (Curve *)ptr->data;
   Nurb *nu = value.data;
index 2574fb1..1edcbf0 100644 (file)
@@ -239,7 +239,9 @@ static void rna_DriverTarget_update_name(Main *bmain, Scene *scene, PointerRNA *
 /* ----------- */
 
 /* note: this function exists only to avoid id refcounting */
-static void rna_DriverTarget_id_set(PointerRNA *ptr, PointerRNA value)
+static void rna_DriverTarget_id_set(struct ReportList *UNUSED(reports),
+                                    PointerRNA *ptr,
+                                    PointerRNA value)
 {
   DriverTarget *dtar = (DriverTarget *)ptr->data;
   dtar->id = value.data;
@@ -446,7 +448,9 @@ static void rna_FCurve_RnaPath_set(PointerRNA *ptr, const char *value)
     fcu->rna_path = NULL;
 }
 
-static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
+static void rna_FCurve_group_set(struct ReportList *UNUSED(reports),
+                                 PointerRNA *ptr,
+                                 PointerRNA value)
 {
   ID *pid = (ID *)ptr->id.data;
   ID *vid = (ID *)value.id.data;
@@ -566,7 +570,9 @@ static PointerRNA rna_FCurve_active_modifier_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_FModifier, fcm);
 }
 
-static void rna_FCurve_active_modifier_set(PointerRNA *ptr, PointerRNA value)
+static void rna_FCurve_active_modifier_set(struct ReportList *UNUSED(reports),
+                                           PointerRNA *ptr,
+                                           PointerRNA value)
 {
   FCurve *fcu = (FCurve *)ptr->data;
   set_active_fmodifier(&fcu->modifiers, (FModifier *)value.data);
index 8d3bfdd..c7071ee 100644 (file)
@@ -281,7 +281,9 @@ static void set_parent(bGPDlayer *gpl, Object *par, const int type, const char *
 }
 
 /* set parent object and inverse matrix */
-static void rna_GPencilLayer_parent_set(PointerRNA *ptr, PointerRNA value)
+static void rna_GPencilLayer_parent_set(struct ReportList *UNUSED(reports),
+                                        PointerRNA *ptr,
+                                        PointerRNA value)
 {
   bGPDlayer *gpl = (bGPDlayer *)ptr->data;
   Object *par = (Object *)value.data;
@@ -375,7 +377,9 @@ static PointerRNA rna_GPencil_active_layer_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, NULL, NULL);
 }
 
-static void rna_GPencil_active_layer_set(PointerRNA *ptr, PointerRNA value)
+static void rna_GPencil_active_layer_set(struct ReportList *UNUSED(reports),
+                                         PointerRNA *ptr,
+                                         PointerRNA value)
 {
   bGPdata *gpd = ptr->id.data;
 
index d1ae46a..afefa66 100644 (file)
@@ -296,7 +296,8 @@ static void greasepencil_modifier_object_set(Object *self,
 }
 
 #  define RNA_GP_MOD_OBJECT_SET(_type, _prop, _obtype) \
-    static void rna_##_type##GpencilModifier_##_prop##_set(PointerRNA *ptr, PointerRNA value) \
+    static void rna_##_type##GpencilModifier_##_prop##_set( \
+        struct ReportList *UNUSED(reports), PointerRNA *ptr, PointerRNA value) \
     { \
       _type##GpencilModifierData *tmd = (_type##GpencilModifierData *)ptr->data; \
       greasepencil_modifier_object_set(ptr->id.data, &tmd->_prop, _obtype, value); \
@@ -308,7 +309,9 @@ RNA_GP_MOD_OBJECT_SET(Mirror, object, OB_EMPTY);
 
 #  undef RNA_GP_MOD_OBJECT_SET
 
-static void rna_HookGpencilModifier_object_set(PointerRNA *ptr, PointerRNA value)
+static void rna_HookGpencilModifier_object_set(struct ReportList *UNUSED(reports),
+                                               PointerRNA *ptr,
+                                               PointerRNA value)
 {
   HookGpencilModifierData *hmd = ptr->data;
   Object *ob = (Object *)value.data;
index 83ec332..40c8c7e 100644 (file)
@@ -479,7 +479,9 @@ static PointerRNA rna_render_slots_active_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_RenderSlot, render_slot);
 }
 
-static void rna_render_slots_active_set(PointerRNA *ptr, PointerRNA value)
+static void rna_render_slots_active_set(struct ReportList *UNUSED(reports),
+                                        PointerRNA *ptr,
+                                        PointerRNA value)
 {
   Image *image = (Image *)ptr->id.data;
   if (value.id.data == image) {
index 938db92..0f71eec 100644 (file)
@@ -277,7 +277,9 @@ int rna_object_shapekey_index_set(struct ID *id, PointerRNA value, int current);
 /* ViewLayer related functions defined in rna_scene.c but required in rna_layer.c */
 void rna_def_freestyle_settings(struct BlenderRNA *brna);
 struct PointerRNA rna_FreestyleLineSet_linestyle_get(struct PointerRNA *ptr);
-void rna_FreestyleLineSet_linestyle_set(struct PointerRNA *ptr, struct PointerRNA value);
+void rna_FreestyleLineSet_linestyle_set(struct ReportList *reports,
+                                        struct PointerRNA *ptr,
+                                        struct PointerRNA value);
 struct FreestyleLineSet *rna_FreestyleSettings_lineset_add(struct ID *id,
                                                            struct FreestyleSettings *config,
                                                            struct Main *bmain,
index 92c895b..14d850b 100644 (file)
@@ -37,6 +37,7 @@ struct IDProperty;
 struct Main;
 struct PointerRNA;
 struct PropertyRNA;
+struct ReportList;
 struct Scene;
 struct StructRNA;
 struct bContext;
@@ -85,7 +86,9 @@ typedef const EnumPropertyItem *(*PropEnumItemFunc)(struct bContext *C,
                                                     bool *r_free);
 typedef PointerRNA (*PropPointerGetFunc)(struct PointerRNA *ptr);
 typedef StructRNA *(*PropPointerTypeFunc)(struct PointerRNA *ptr);
-typedef void (*PropPointerSetFunc)(struct PointerRNA *ptr, const PointerRNA value);
+typedef void (*PropPointerSetFunc)(struct ReportList *reports,
+                                   struct PointerRNA *ptr,
+                                   const PointerRNA value);
 typedef bool (*PropPointerPollFunc)(struct PointerRNA *ptr, const PointerRNA value);
 typedef bool (*PropPointerPollFuncPy)(struct PointerRNA *ptr,
                                       const PointerRNA value,
index 1985099..65233d5 100644 (file)
@@ -316,7 +316,9 @@ static PointerRNA rna_ShapeKey_relative_key_get(PointerRNA *ptr)
   return rna_object_shapekey_index_get(ptr->id.data, kb->relative);
 }
 
-static void rna_ShapeKey_relative_key_set(PointerRNA *ptr, PointerRNA value)
+static void rna_ShapeKey_relative_key_set(struct ReportList *UNUSED(reports),
+                                          PointerRNA *ptr,
+                                          PointerRNA value)
 {
   KeyBlock *kb = (KeyBlock *)ptr->data;
 
index c8af49c..0f8a2ee 100644 (file)
@@ -67,7 +67,9 @@ static PointerRNA rna_ViewLayer_active_layer_collection_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_LayerCollection, lc);
 }
 
-static void rna_ViewLayer_active_layer_collection_set(PointerRNA *ptr, PointerRNA value)
+static void rna_ViewLayer_active_layer_collection_set(struct ReportList *UNUSED(reports),
+                                                      PointerRNA *ptr,
+                                                      PointerRNA value)
 {
   ViewLayer *view_layer = (ViewLayer *)ptr->data;
   LayerCollection *lc = (LayerCollection *)value.data;
@@ -84,7 +86,9 @@ static PointerRNA rna_LayerObjects_active_object_get(PointerRNA *ptr)
       ptr, &RNA_Object, view_layer->basact ? view_layer->basact->object : NULL);
 }
 
-static void rna_LayerObjects_active_object_set(PointerRNA *ptr, PointerRNA value)
+static void rna_LayerObjects_active_object_set(struct ReportList *UNUSED(reports),
+                                               PointerRNA *ptr,
+                                               PointerRNA value)
 {
   ViewLayer *view_layer = (ViewLayer *)ptr->data;
   if (value.data)
index 3a6f283..b98b21a 100644 (file)
@@ -356,7 +356,9 @@ static PointerRNA rna_LineStyle_active_texture_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex);
 }
 
-static void rna_LineStyle_active_texture_set(PointerRNA *ptr, PointerRNA value)
+static void rna_LineStyle_active_texture_set(struct ReportList *UNUSED(reports),
+                                             PointerRNA *ptr,
+                                             PointerRNA value)
 {
   FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->id.data;
 
index abcaccd..bd06cfc 100644 (file)
@@ -208,6 +208,13 @@ static void rna_Main_scenes_remove(
 
 static Object *rna_Main_objects_new(Main *bmain, ReportList *reports, const char *name, ID *data)
 {
+  if (data != NULL && (data->tag & LIB_TAG_NO_MAIN)) {
+    BKE_report(reports,
+               RPT_ERROR,
+               "Can not create object in main database with an evaluated data data-block");
+    return NULL;
+  }
+
   char safe_name[MAX_ID_NAME - 2];
   rna_idname_validate(name, safe_name);
 
index 8b27c69..563372d 100644 (file)
@@ -116,7 +116,9 @@ static void rna_Mask_update_parent(Main *bmain, Scene *scene, PointerRNA *ptr)
 }
 
 /* note: this function exists only to avoid id refcounting */
-static void rna_MaskParent_id_set(PointerRNA *ptr, PointerRNA value)
+static void rna_MaskParent_id_set(struct ReportList *UNUSED(reports),
+                                  PointerRNA *ptr,
+                                  PointerRNA value)
 {
   MaskParent *mpar = (MaskParent *)ptr->data;
 
@@ -191,7 +193,9 @@ static PointerRNA rna_Mask_layer_active_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_MaskLayer, masklay);
 }
 
-static void rna_Mask_layer_active_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Mask_layer_active_set(struct ReportList *UNUSED(reports),
+                                      PointerRNA *ptr,
+                                      PointerRNA value)
 {
   Mask *mask = (Mask *)ptr->id.data;
   MaskLayer *masklay = (MaskLayer *)value.data;
@@ -226,7 +230,9 @@ static PointerRNA rna_MaskLayer_active_spline_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_MaskSpline, masklay->act_spline);
 }
 
-static void rna_MaskLayer_active_spline_set(PointerRNA *ptr, PointerRNA value)
+static void rna_MaskLayer_active_spline_set(struct ReportList *UNUSED(reports),
+                                            PointerRNA *ptr,
+                                            PointerRNA value)
 {
   MaskLayer *masklay = (MaskLayer *)ptr->data;
   MaskSpline *spline = (MaskSpline *)value.data;
@@ -245,7 +251,9 @@ static PointerRNA rna_MaskLayer_active_spline_point_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_MaskSplinePoint, masklay->act_point);
 }
 
-static void rna_MaskLayer_active_spline_point_set(PointerRNA *ptr, PointerRNA value)
+static void rna_MaskLayer_active_spline_point_set(struct ReportList *UNUSED(reports),
+                                                  PointerRNA *ptr,
+                                                  PointerRNA value)
 {
   MaskLayer *masklay = (MaskLayer *)ptr->data;
   MaskSpline *spline;
index edfdbe2..93dc7fe 100644 (file)
@@ -330,7 +330,9 @@ static int rna_GpencilColorData_is_fill_visible_get(PointerRNA *ptr)
   return ((pcolor->fill_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH) || (pcolor->fill_style > 0));
 }
 
-static void rna_GpencilColorData_stroke_image_set(PointerRNA *ptr, PointerRNA value)
+static void rna_GpencilColorData_stroke_image_set(struct ReportList *UNUSED(reports),
+                                                  PointerRNA *ptr,
+                                                  PointerRNA value)
 {
   MaterialGPencilStyle *pcolor = ptr->data;
   ID *id = value.data;
@@ -339,7 +341,9 @@ static void rna_GpencilColorData_stroke_image_set(PointerRNA *ptr, PointerRNA va
   pcolor->sima = (struct Image *)id;
 }
 
-static void rna_GpencilColorData_fill_image_set(PointerRNA *ptr, PointerRNA value)
+static void rna_GpencilColorData_fill_image_set(struct ReportList *UNUSED(reports),
+                                                PointerRNA *ptr,
+                                                PointerRNA value)
 {
   MaterialGPencilStyle *pcolor = (MaterialGPencilStyle *)ptr->data;
   ID *id = value.data;
index ff14840..2da35b5 100644 (file)
@@ -83,7 +83,8 @@
     return rna_pointer_inherit_refine(ptr, &RNA_##layer_rna_type, layer); \
   } \
 \
-  static void rna_Mesh_##collection_name##_##active_type##_set(PointerRNA *ptr, PointerRNA value) \
+  static void rna_Mesh_##collection_name##_##active_type##_set( \
+      struct ReportList *UNUSED(reports), PointerRNA *ptr, PointerRNA value) \
   { \
     Mesh *me = rna_mesh(ptr); \
     CustomData *data = rna_mesh_##customdata_type(ptr); \
index a3abf02..28d02c6 100644 (file)
@@ -719,7 +719,8 @@ static void modifier_object_set(Object *self, Object **ob_p, int type, PointerRN
 }
 
 #  define RNA_MOD_OBJECT_SET(_type, _prop, _obtype) \
-    static void rna_##_type##Modifier_##_prop##_set(PointerRNA *ptr, PointerRNA value) \
+    static void rna_##_type##Modifier_##_prop##_set( \
+        struct ReportList *UNUSED(reports), PointerRNA *ptr, PointerRNA value) \
     { \
       _type##ModifierData *tmd = (_type##ModifierData *)ptr->data; \
       modifier_object_set(ptr->id.data, &tmd->_prop, _obtype, value); \
@@ -741,7 +742,9 @@ RNA_MOD_OBJECT_SET(Shrinkwrap, target, OB_MESH);
 RNA_MOD_OBJECT_SET(Shrinkwrap, auxTarget, OB_MESH);
 RNA_MOD_OBJECT_SET(SurfaceDeform, target, OB_MESH);
 
-static void rna_HookModifier_object_set(PointerRNA *ptr, PointerRNA value)
+static void rna_HookModifier_object_set(struct ReportList *UNUSED(reports),
+                                        PointerRNA *ptr,
+                                        PointerRNA value)
 {
   Object *owner = (Object *)ptr->id.data;
   HookModifierData *hmd = ptr->data;
@@ -824,7 +827,9 @@ static PointerRNA rna_UVProjector_object_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_Object, *ob);
 }
 
-static void rna_UVProjector_object_set(PointerRNA *ptr, PointerRNA value)
+static void rna_UVProjector_object_set(struct ReportList *UNUSED(reports),
+                                       PointerRNA *ptr,
+                                       PointerRNA value)
 {
   Object **ob_p = (Object **)ptr->data;
   Object *ob = (Object *)value.data;
@@ -1396,7 +1401,8 @@ static PointerRNA rna_ParticleInstanceModifier_particle_system_get(PointerRNA *p
   return rptr;
 }
 
-static void rna_ParticleInstanceModifier_particle_system_set(PointerRNA *ptr,
+static void rna_ParticleInstanceModifier_particle_system_set(struct ReportList *UNUSED(reports),
+                                                             PointerRNA *ptr,
                                                              const PointerRNA value)
 {
   ParticleInstanceModifierData *psmd = ptr->data;
index 4906f8a..17072a6 100644 (file)
@@ -814,7 +814,9 @@ static PointerRNA rna_NodeTree_active_node_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_Node, node);
 }
 
-static void rna_NodeTree_active_node_set(PointerRNA *ptr, const PointerRNA value)
+static void rna_NodeTree_active_node_set(struct ReportList *UNUSED(reports),
+                                         PointerRNA *ptr,
+                                         const PointerRNA value)
 {
   bNodeTree *ntree = (bNodeTree *)ptr->data;
   bNode *node = (bNode *)value.data;
@@ -1608,7 +1610,9 @@ static IDProperty *rna_Node_idprops(PointerRNA *ptr, bool create)
   return node->prop;
 }
 
-static void rna_Node_parent_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Node_parent_set(struct ReportList *UNUSED(reports),
+                                PointerRNA *ptr,
+                                PointerRNA value)
 {
   bNode *node = ptr->data;
   bNode *parent = value.data;
@@ -2683,7 +2687,9 @@ static void rna_NodeGroup_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *
   ED_node_tag_update_nodetree(bmain, ntree, node);
 }
 
-static void rna_NodeGroup_node_tree_set(PointerRNA *ptr, const PointerRNA value)
+static void rna_NodeGroup_node_tree_set(struct ReportList *UNUSED(reports),
+                                        PointerRNA *ptr,
+                                        const PointerRNA value)
 {
   bNodeTree *ntree = ptr->id.data;
   bNode *node = ptr->data;
@@ -2791,7 +2797,9 @@ static void rna_Matte_t2_set(PointerRNA *ptr, float value)
   chroma->t2 = value;
 }
 
-static void rna_Node_scene_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Node_scene_set(struct ReportList *UNUSED(reports),
+                               PointerRNA *ptr,
+                               PointerRNA value)
 {
   bNode *node = (bNode *)ptr->data;
 
@@ -3345,7 +3353,9 @@ static PointerRNA rna_ShaderNodePointDensity_psys_get(PointerRNA *ptr)
   return value;
 }
 
-static void rna_ShaderNodePointDensity_psys_set(PointerRNA *ptr, PointerRNA value)
+static void rna_ShaderNodePointDensity_psys_set(struct ReportList *UNUSED(reports),
+                                                PointerRNA *ptr,
+                                                PointerRNA value)
 {
   bNode *node = ptr->data;
   NodeShaderTexPointDensity *shader_point_density = node->storage;
index b2cbfbb..b445399 100644 (file)
@@ -427,7 +427,7 @@ static void rna_Object_dependency_update(Main *bmain, Scene *UNUSED(scene), Poin
   WM_main_add_notifier(NC_OBJECT | ND_PARENT, ptr->id.data);
 }
 
-static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Object_data_set(struct ReportList *reports, PointerRNA *ptr, PointerRNA value)
 {
   Object *ob = (Object *)ptr->data;
   ID *id = value.data;
@@ -441,8 +441,13 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
     return;
   }
 
-  BLI_assert(BKE_id_is_in_global_main(&ob->id));
-  BLI_assert(BKE_id_is_in_global_main(id));
+  if ((id->tag & LIB_TAG_NO_MAIN) != (ob->id.tag & LIB_TAG_NO_MAIN)) {
+    BKE_report(reports,
+               RPT_ERROR,
+               "Can only assign evaluated data to to evaluated object, or original data to "
+               "original object");
+    return;
+  }
 
   if (ob->type == OB_EMPTY) {
     if (ob->data) {
@@ -529,7 +534,9 @@ static bool rna_Object_data_poll(PointerRNA *ptr, const PointerRNA value)
   return true;
 }
 
-static void rna_Object_parent_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Object_parent_set(struct ReportList *UNUSED(reports),
+                                  PointerRNA *ptr,
+                                  PointerRNA value)
 {
   Object *ob = (Object *)ptr->data;
   Object *par = (Object *)value.data;
@@ -614,7 +621,9 @@ static const EnumPropertyItem *rna_Object_instance_type_itemf(bContext *UNUSED(C
   return item;
 }
 
-static void rna_Object_dup_collection_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Object_dup_collection_set(struct ReportList *UNUSED(reports),
+                                          PointerRNA *ptr,
+                                          PointerRNA value)
 {
   Object *ob = (Object *)ptr->data;
   Collection *grp = (Collection *)value.data;
@@ -890,7 +899,9 @@ static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
 }
 
-static void rna_Object_active_material_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Object_active_material_set(struct ReportList *UNUSED(reports),
+                                           PointerRNA *ptr,
+                                           PointerRNA value)
 {
   Object *ob = (Object *)ptr->id.data;
 
@@ -1089,7 +1100,9 @@ static PointerRNA rna_MaterialSlot_material_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
 }
 
-static void rna_MaterialSlot_material_set(PointerRNA *ptr, PointerRNA value)
+static void rna_MaterialSlot_material_set(struct ReportList *UNUSED(reports),
+                                          PointerRNA *ptr,
+                                          PointerRNA value)
 {
   Object *ob = (Object *)ptr->id.data;
   int index = (Material **)ptr->data - ob->mat;
@@ -1277,7 +1290,9 @@ static PointerRNA rna_Object_active_constraint_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con);
 }
 
-static void rna_Object_active_constraint_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Object_active_constraint_set(struct ReportList *UNUSED(reports),
+                                             PointerRNA *ptr,
+                                             PointerRNA value)
 {
   Object *ob = (Object *)ptr->id.data;
   BKE_constraints_active_set(&ob->constraints, (bConstraint *)value.data);
index 7b35092..cd6ed9b 100644 (file)
@@ -74,7 +74,9 @@ static PointerRNA rna_Palette_active_color_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, NULL, NULL);
 }
 
-static void rna_Palette_active_color_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Palette_active_color_set(struct ReportList *UNUSED(reports),
+                                         PointerRNA *ptr,
+                                         PointerRNA value)
 {
   Palette *palette = ptr->data;
   PaletteColor *color = value.data;
index 8c3d16f..9ef5bcd 100644 (file)
@@ -792,7 +792,9 @@ static PointerRNA rna_particle_settings_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_ParticleSettings, part);
 }
 
-static void rna_particle_settings_set(PointerRNA *ptr, PointerRNA value)
+static void rna_particle_settings_set(struct ReportList *UNUSED(reports),
+                                      PointerRNA *ptr,
+                                      PointerRNA value)
 {
   Object *ob = ptr->id.data;
   ParticleSystem *psys = (ParticleSystem *)ptr->data;
@@ -1318,7 +1320,9 @@ static PointerRNA rna_ParticleSettings_active_texture_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex);
 }
 
-static void rna_ParticleSettings_active_texture_set(PointerRNA *ptr, PointerRNA value)
+static void rna_ParticleSettings_active_texture_set(struct ReportList *UNUSED(reports),
+                                                    PointerRNA *ptr,
+                                                    PointerRNA value)
 {
   ParticleSettings *part = (ParticleSettings *)ptr->data;
 
index 2f7f8c7..7b91248 100644 (file)
@@ -373,7 +373,9 @@ static void rna_Itasc_update_rebuild(Main *bmain, Scene *scene, PointerRNA *ptr)
   rna_Itasc_update(bmain, scene, ptr);
 }
 
-static void rna_PoseChannel_bone_custom_set(PointerRNA *ptr, PointerRNA value)
+static void rna_PoseChannel_bone_custom_set(struct ReportList *UNUSED(reports),
+                                            PointerRNA *ptr,
+                                            PointerRNA value)
 {
   bPoseChannel *pchan = (bPoseChannel *)ptr->data;
 
@@ -402,7 +404,9 @@ static PointerRNA rna_PoseChannel_bone_group_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_BoneGroup, grp);
 }
 
-static void rna_PoseChannel_bone_group_set(PointerRNA *ptr, PointerRNA value)
+static void rna_PoseChannel_bone_group_set(struct ReportList *UNUSED(reports),
+                                           PointerRNA *ptr,
+                                           PointerRNA value)
 {
   Object *ob = (Object *)ptr->id.data;
   bPose *pose = (ob) ? ob->pose : NULL;
@@ -443,7 +447,9 @@ static PointerRNA rna_Pose_active_bone_group_get(PointerRNA *ptr)
       ptr, &RNA_BoneGroup, BLI_findlink(&pose->agroups, pose->active_group - 1));
 }
 
-static void rna_Pose_active_bone_group_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Pose_active_bone_group_set(struct ReportList *UNUSED(reports),
+                                           PointerRNA *ptr,
+                                           PointerRNA value)
 {
   bPose *pose = (bPose *)ptr->data;
   pose->active_group = BLI_findindex(&pose->agroups, value.data) + 1;
@@ -532,7 +538,9 @@ static PointerRNA rna_PoseChannel_active_constraint_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_Constraint, con);
 }
 
-static void rna_PoseChannel_active_constraint_set(PointerRNA *ptr, PointerRNA value)
+static void rna_PoseChannel_active_constraint_set(struct ReportList *UNUSED(reports),
+                                                  PointerRNA *ptr,
+                                                  PointerRNA value)
 {
   bPoseChannel *pchan = (bPoseChannel *)ptr->data;
   BKE_constraints_active_set(&pchan->constraints, (bConstraint *)value.data);
@@ -770,7 +778,9 @@ static bPoseChannel *rna_PoseChannel_ensure_own_pchan(Object *ob,
   return ref_pchan;
 }
 
-static void rna_PoseChannel_custom_shape_transform_set(PointerRNA *ptr, PointerRNA value)
+static void rna_PoseChannel_custom_shape_transform_set(struct ReportList *UNUSED(reports),
+                                                       PointerRNA *ptr,
+                                                       PointerRNA value)
 {
   bPoseChannel *pchan = (bPoseChannel *)ptr->data;
   Object *ob = (Object *)ptr->id.data;
index 032a1f8..c5eff47 100644 (file)
@@ -2373,7 +2373,7 @@ bool rna_property_override_apply_default(Main *UNUSED(bmain),
 
       switch (override_op) {
         case IDOVERRIDESTATIC_OP_REPLACE:
-          RNA_property_pointer_set(ptr_dst, prop_dst, value);
+          RNA_property_pointer_set(NULL, ptr_dst, prop_dst, value);
           break;
         default:
           BLI_assert(0 && "Unsupported RNA override operation on pointer");
index 5733b31..4584cad 100644 (file)
@@ -772,7 +772,9 @@ static PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter)
 
 /* End of read-only Iterator of all the scene objects. */
 
-static void rna_Scene_set_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Scene_set_set(struct ReportList *UNUSED(reports),
+                              PointerRNA *ptr,
+                              PointerRNA value)
 {
   Scene *scene = (Scene *)ptr->data;
   Scene *set = (Scene *)value.data;
@@ -969,7 +971,9 @@ static PointerRNA rna_Scene_active_keying_set_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_KeyingSet, ANIM_scene_get_active_keyingset(scene));
 }
 
-static void rna_Scene_active_keying_set_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Scene_active_keying_set_set(struct ReportList *UNUSED(reports),
+                                            PointerRNA *ptr,
+                                            PointerRNA value)
 {
   Scene *scene = (Scene *)ptr->data;
   KeyingSet *ks = (KeyingSet *)value.data;
@@ -1435,7 +1439,9 @@ static PointerRNA rna_RenderSettings_active_view_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_SceneRenderView, srv);
 }
 
-static void rna_RenderSettings_active_view_set(PointerRNA *ptr, PointerRNA value)
+static void rna_RenderSettings_active_view_set(struct ReportList *UNUSED(reports),
+                                               PointerRNA *ptr,
+                                               PointerRNA value)
 {
   RenderData *rd = (RenderData *)ptr->data;
   SceneRenderView *srv = (SceneRenderView *)value.data;
@@ -2040,7 +2046,9 @@ PointerRNA rna_FreestyleLineSet_linestyle_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_FreestyleLineStyle, lineset->linestyle);
 }
 
-void rna_FreestyleLineSet_linestyle_set(PointerRNA *ptr, PointerRNA value)
+void rna_FreestyleLineSet_linestyle_set(struct ReportList *UNUSED(reports),
+                                        PointerRNA *ptr,
+                                        PointerRNA value)
 {
   FreestyleLineSet *lineset = (FreestyleLineSet *)ptr->data;
 
index 2af06fc..687ba96 100644 (file)
@@ -465,7 +465,9 @@ static void rna_SequenceCrop_update(Main *UNUSED(bmain), Scene *UNUSED(scene), P
   BKE_sequence_invalidate_cache(scene, seq);
 }
 
-static void rna_Sequence_text_font_set(PointerRNA *ptr, PointerRNA ptr_value)
+static void rna_Sequence_text_font_set(struct ReportList *UNUSED(reports),
+                                       PointerRNA *ptr,
+                                       PointerRNA ptr_value)
 {
   Sequence *seq = ptr->data;
   TextVars *data = seq->effectdata;
index 06c9685..8696023 100644 (file)
@@ -185,7 +185,8 @@ static void shaderfx_object_set(Object *self, Object **ob_p, int type, PointerRN
 }
 
 #  define RNA_FX_OBJECT_SET(_type, _prop, _obtype) \
-    static void rna_##_type##ShaderFx_##_prop##_set(PointerRNA *ptr, PointerRNA value) \
+    static void rna_##_type##ShaderFx_##_prop##_set( \
+        struct ReportList *UNUSED(reports), PointerRNA *ptr, PointerRNA value) \
     { \
       _type##ShaderFxData *tmd = (_type##ShaderFxData *)ptr->data; \
       shaderfx_object_set(ptr->id.data, &tmd->_prop, _obtype, value); \
index 6163084..0611cca 100644 (file)
@@ -1329,7 +1329,9 @@ static bool rna_SpaceImageEditor_show_maskedit_get(PointerRNA *ptr)
   return ED_space_image_check_show_maskedit(sima, view_layer);
 }
 
-static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value)
+static void rna_SpaceImageEditor_image_set(struct ReportList *UNUSED(reports),
+                                           PointerRNA *ptr,
+                                           PointerRNA value)
 {
   SpaceImage *sima = (SpaceImage *)(ptr->data);
   bScreen *sc = (bScreen *)ptr->id.data;
@@ -1341,7 +1343,9 @@ static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value)
   ED_space_image_set(G_MAIN, sima, obedit, (Image *)value.data, false);
 }
 
-static void rna_SpaceImageEditor_mask_set(PointerRNA *ptr, PointerRNA value)
+static void rna_SpaceImageEditor_mask_set(struct ReportList *UNUSED(reports),
+                                          PointerRNA *ptr,
+                                          PointerRNA value)
 {
   SpaceImage *sima = (SpaceImage *)(ptr->data);
 
@@ -1507,7 +1511,9 @@ static void rna_SpaceTextEditor_word_wrap_set(PointerRNA *ptr, bool value)
   st->left = 0;
 }
 
-static void rna_SpaceTextEditor_text_set(PointerRNA *ptr, PointerRNA value)
+static void rna_SpaceTextEditor_text_set(struct ReportList *UNUSED(reports),
+                                         PointerRNA *ptr,
+                                         PointerRNA value)
 {
   SpaceText *st = (SpaceText *)(ptr->data);
 
@@ -1529,7 +1535,9 @@ static void rna_SpaceTextEditor_updateEdited(Main *UNUSED(bmain),
 /* Space Properties */
 
 /* note: this function exists only to avoid id refcounting */
-static void rna_SpaceProperties_pin_id_set(PointerRNA *ptr, PointerRNA value)
+static void rna_SpaceProperties_pin_id_set(struct ReportList *UNUSED(reports),
+                                           PointerRNA *ptr,
+                                           PointerRNA value)
 {
   SpaceProperties *sbuts = (SpaceProperties *)(ptr->data);
   sbuts->pinid = value.data;
@@ -1731,7 +1739,9 @@ static void rna_ConsoleLine_cursor_index_range(
 
 /* Space Dopesheet */
 
-static void rna_SpaceDopeSheetEditor_action_set(PointerRNA *ptr, PointerRNA value)
+static void rna_SpaceDopeSheetEditor_action_set(struct ReportList *UNUSED(reports),
+                                                PointerRNA *ptr,
+                                                PointerRNA value)
 {
   SpaceAction *saction = (SpaceAction *)(ptr->data);
   bAction *act = (bAction *)value.data;
@@ -1953,7 +1963,9 @@ static void rna_Sequencer_view_type_update(Main *UNUSED(bmain),
 
 /* Space Node Editor */
 
-static void rna_SpaceNodeEditor_node_tree_set(PointerRNA *ptr, const PointerRNA value)
+static void rna_SpaceNodeEditor_node_tree_set(struct ReportList *UNUSED(reports),
+                                              PointerRNA *ptr,
+                                              const PointerRNA value)
 {
   SpaceNode *snode = (SpaceNode *)ptr->data;
   ED_node_tree_start(snode, (bNodeTree *)value.data, NULL, NULL);
@@ -2064,7 +2076,9 @@ static void rna_SpaceNodeEditor_cursor_location_from_region(SpaceNode *snode,
   snode->cursor[1] /= UI_DPI_FAC;
 }
 
-static void rna_SpaceClipEditor_clip_set(PointerRNA *ptr, PointerRNA value)
+static void rna_SpaceClipEditor_clip_set(struct ReportList *UNUSED(reports),
+                                         PointerRNA *ptr,
+                                         PointerRNA value)
 {
   SpaceClip *sc = (SpaceClip *)(ptr->data);
   bScreen *screen = (bScreen *)ptr->id.data;
@@ -2072,7 +2086,9 @@ static void rna_SpaceClipEditor_clip_set(PointerRNA *ptr, PointerRNA value)
   ED_space_clip_set_clip(NULL, screen, sc, (MovieClip *)value.data);
 }
 
-static void rna_SpaceClipEditor_mask_set(PointerRNA *ptr, PointerRNA value)
+static void rna_SpaceClipEditor_mask_set(struct ReportList *UNUSED(reports),
+                                         PointerRNA *ptr,
+                                         PointerRNA value)
 {
   SpaceClip *sc = (SpaceClip *)(ptr->data);
 
index 1fbdac9..9be277a 100644 (file)
@@ -144,7 +144,9 @@ static PointerRNA rna_tracking_active_track_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_MovieTrackingTrack, act_track);
 }
 
-static void rna_tracking_active_track_set(PointerRNA *ptr, PointerRNA value)
+static void rna_tracking_active_track_set(struct ReportList *UNUSED(reports),
+                                          PointerRNA *ptr,
+                                          PointerRNA value)
 {
   MovieClip *clip = (MovieClip *)ptr->id.data;
   MovieTrackingTrack *track = (MovieTrackingTrack *)value.data;
@@ -165,7 +167,9 @@ static PointerRNA rna_tracking_active_plane_track_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_MovieTrackingPlaneTrack, act_plane_track);
 }
 
-static void rna_tracking_active_plane_track_set(PointerRNA *ptr, PointerRNA value)
+static void rna_tracking_active_plane_track_set(struct ReportList *UNUSED(reports),
+                                                PointerRNA *ptr,
+                                                PointerRNA value)
 {
   MovieClip *clip = (MovieClip *)ptr->id.data;
   MovieTrackingPlaneTrack *plane_track = (MovieTrackingPlaneTrack *)value.data;
@@ -476,7 +480,9 @@ static PointerRNA rna_tracking_active_object_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_MovieTrackingObject, object);
 }
 
-static void rna_tracking_active_object_set(PointerRNA *ptr, PointerRNA value)
+static void rna_tracking_active_object_set(struct ReportList *UNUSED(reports),
+                                           PointerRNA *ptr,
+                                           PointerRNA value)
 {
   MovieClip *clip = (MovieClip *)ptr->id.data;
   MovieTrackingObject *object = (MovieTrackingObject *)value.data;
index e4af1b5..f3080d6 100644 (file)
@@ -694,7 +694,9 @@ static PointerRNA rna_PieMenu_layout_get(PointerRNA *ptr)
   return rptr;
 }
 
-static void rna_Window_scene_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Window_scene_set(struct ReportList *UNUSED(reports),
+                                 PointerRNA *ptr,
+                                 PointerRNA value)
 {
   wmWindow *win = ptr->data;
 
@@ -738,7 +740,9 @@ static PointerRNA rna_Window_workspace_get(PointerRNA *ptr)
       ptr, &RNA_WorkSpace, BKE_workspace_active_get(win->workspace_hook));
 }
 
-static void rna_Window_workspace_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Window_workspace_set(struct ReportList *UNUSED(reports),
+                                     PointerRNA *ptr,
+                                     PointerRNA value)
 {
   wmWindow *win = (wmWindow *)ptr->data;
 
@@ -774,7 +778,9 @@ PointerRNA rna_Window_screen_get(PointerRNA *ptr)
       ptr, &RNA_Screen, BKE_workspace_active_screen_get(win->workspace_hook));
 }
 
-static void rna_Window_screen_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Window_screen_set(struct ReportList *UNUSED(reports),
+                                  PointerRNA *ptr,
+                                  PointerRNA value)
 {
   wmWindow *win = ptr->data;
   WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
@@ -824,7 +830,9 @@ static PointerRNA rna_Window_view_layer_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(&scene_ptr, &RNA_ViewLayer, view_layer);
 }
 
-static void rna_Window_view_layer_set(PointerRNA *ptr, PointerRNA value)
+static void rna_Window_view_layer_set(struct ReportList *UNUSED(reports),
+                                      PointerRNA *ptr,
+                                      PointerRNA value)
 {
   wmWindow *win = ptr->data;
   ViewLayer *view_layer = value.data;
@@ -1028,7 +1036,9 @@ static PointerRNA rna_WindowManager_active_keyconfig_get(PointerRNA *ptr)
   return rna_pointer_inherit_refine(ptr, &RNA_KeyConfig, kc);
 }
 
-static void rna_WindowManager_active_keyconfig_set(PointerRNA *ptr, PointerRNA value)
+static void rna_WindowManager_active_keyconfig_set(struct ReportList *UNUSED(reports),
+                                                   PointerRNA *ptr,
+                                                   PointerRNA value)
 {
   wmWindowManager *wm = ptr->data;
   wmKeyConfig *kc = value.data;
index 819dc3a..e5487a6 100644 (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;