Merged changes in the trunk up to revision 51853.
[blender-staging.git] / source / blender / makesrna / intern / rna_space.c
index ecb2bf71cb2130f7dd83b993c88ba6c08d642d37..70daba9790f4ccd73c6a96a349f10d8065356396 100644 (file)
@@ -958,15 +958,17 @@ static BGpic *rna_BackgroundImage_new(View3D *v3d)
        return bgpic;
 }
 
-static void rna_BackgroundImage_remove(View3D *v3d, ReportList *reports, BGpic *bgpic)
+static void rna_BackgroundImage_remove(View3D *v3d, ReportList *reports, PointerRNA *bgpic_ptr)
 {
+       BGpic *bgpic = bgpic_ptr->data;
        if (BLI_findindex(&v3d->bgpicbase, bgpic) == -1) {
                BKE_report(reports, RPT_ERROR, "Background image cannot be removed");
        }
-       else {
-               ED_view3D_background_image_remove(v3d, bgpic);
-               WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, v3d);
-       }
+
+       ED_view3D_background_image_remove(v3d, bgpic);
+       RNA_POINTER_INVALIDATE(bgpic_ptr);
+
+       WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, v3d);
 }
 
 static void rna_BackgroundImage_clear(View3D *v3d)
@@ -1451,7 +1453,8 @@ static void rna_def_backgroundImages(BlenderRNA *brna, PropertyRNA *cprop)
        RNA_def_function_ui_description(func, "Remove background image");
        RNA_def_function_flag(func, FUNC_USE_REPORTS);
        parm = RNA_def_pointer(func, "image", "BackgroundImage", "", "Image displayed as viewport background");
-       RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+       RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
+       RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
 
        func = RNA_def_function(srna, "clear", "rna_BackgroundImage_clear");
        RNA_def_function_ui_description(func, "Remove all background images");