Fix T56912: bpy.data.masks.new() crashed

I think there are two possible ways to fix that.
1. Make the name a required parameter.
2. Provide a default value.

I choosed option 1 in this fix to be consistent with other .new functions.

Also I think `RNA_def_string` instead of `RNA_def_string_file_path` should be used here. Looks like a copy-paste error.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D3728
This commit is contained in:
Jacques Lucke 2018-09-25 12:01:43 +02:00
parent 0083c69624
commit 554b26cf88
Notes: blender-bot 2023-02-14 05:16:29 +01:00
Referenced by issue #56912, Creating a mask from python crashes Blender
1 changed files with 2 additions and 1 deletions

View File

@ -1864,7 +1864,8 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop)
/* new func */
func = RNA_def_function(srna, "new", "rna_Main_mask_new");
RNA_def_function_ui_description(func, "Add a new mask with a given name to the main database");
RNA_def_string_file_path(func, "name", NULL, MAX_ID_NAME - 2, "Mask", "Name of new mask data-block");
parm = RNA_def_string(func, "name", NULL, MAX_ID_NAME - 2, "Mask", "Name of new mask data-block");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
/* return type */
parm = RNA_def_pointer(func, "mask", "Mask", "", "New mask data-block");
RNA_def_function_return(func, parm);