Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_object_api.c
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| static void rna_Object_shape_key_remove(Object *ob, Main *bmain, ReportList *reports, | |||||
| PointerRNA *kb_ptr) | |||||
| { | |||||
| KeyBlock *kb = kb_ptr->data; | |||||
sergey: use context only when it's really needed. Here you can pass `bmain` by using `FUNC_USE_MAIN`… | |||||
| Key *key = BKE_key_from_object(ob); | |||||
| if (key == NULL) { | |||||
| return; | |||||
| } | |||||
| if (BLI_findindex(&key->block, kb) == -1) { | |||||
| BKE_reportf(reports, RPT_ERROR, "ShapeKey not found"); | |||||
| return; | |||||
| } | |||||
| if (!BKE_object_remove_shape_key(bmain, ob, kb)) { | |||||
| BKE_reportf(reports, RPT_ERROR, "Could not remove ShapeKey"); | |||||
| return; | |||||
| } | |||||
| DAG_id_tag_update(&ob->id, OB_RECALC_DATA); | |||||
| WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); | |||||
Not Done Inline ActionsUse WM_main_add_notifier() instead. sergey: Use `WM_main_add_notifier()` instead. | |||||
| RNA_POINTER_INVALIDATE(kb_ptr); | |||||
| } | |||||
Not Done Inline ActionsYes this is need, so access after wont crash from accessing freed memory. campbellbarton: Yes this is need, so access after wont crash from accessing freed memory. | |||||
| static int rna_Object_is_visible(Object *ob, Scene *sce) | static int rna_Object_is_visible(Object *ob, Scene *sce) | ||||
| { | { | ||||
| return !(ob->restrictflag & OB_RESTRICT_VIEW) && (ob->lay & sce->lay); | return !(ob->restrictflag & OB_RESTRICT_VIEW) && (ob->lay & sce->lay); | ||||
| Context not available. | |||||
| RNA_def_property_flag(parm, PROP_RNAPTR); | RNA_def_property_flag(parm, PROP_RNAPTR); | ||||
| RNA_def_function_return(func, parm); | RNA_def_function_return(func, parm); | ||||
| func = RNA_def_function(srna, "shape_key_remove", "rna_Object_shape_key_remove"); | |||||
| RNA_def_function_ui_description(func, "Remove a Shape Key from this object"); | |||||
| RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS); | |||||
| parm = RNA_def_pointer(func, "key", "ShapeKey", "", "Keyblock to be removed"); | |||||
| RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); | |||||
| RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); | |||||
| /* Ray Cast */ | /* Ray Cast */ | ||||
| func = RNA_def_function(srna, "ray_cast", "rna_Object_ray_cast"); | func = RNA_def_function(srna, "ray_cast", "rna_Object_ray_cast"); | ||||
| RNA_def_function_ui_description(func, "Cast a ray onto in object space"); | RNA_def_function_ui_description(func, "Cast a ray onto in object space"); | ||||
| Context not available. | |||||
use context only when it's really needed. Here you can pass bmain by using FUNC_USE_MAIN flag.