RNA: declare flags before calling RNA_def_property_enum_items

RNA_def_property_enum_items checks for PROP_ENUM_FLAG which
doesn't work if the flag is set afterwards.

This can be enforced - although that can be handled separately.

Needed to fix #143980.
This commit is contained in:
Campbell Barton
2025-08-07 17:19:35 +10:00
parent c466d1744b
commit e883a6f803
11 changed files with 22 additions and 25 deletions

View File

@@ -1233,9 +1233,9 @@ static void rna_def_keyingset_info(BlenderRNA *brna)
* other places featuring bl_idname/label/description (i.e. operators)
*/
prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
RNA_def_property_enum_sdna(prop, nullptr, "keyingflag");
RNA_def_property_enum_items(prop, rna_enum_keying_flag_items);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
RNA_def_property_ui_text(prop, "Options", "Keying Set options to use when inserting keyframes");
RNA_define_verify_sdna(true);

View File

@@ -366,9 +366,9 @@ static void rna_def_blendfile_import_item(BlenderRNA *brna)
{0, nullptr, 0, nullptr, nullptr},
};
prop = RNA_def_property(srna, "import_info", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, blend_import_item_import_info_items);
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_enum_items(prop, blend_import_item_import_info_items);
RNA_def_property_ui_text(
prop, "Import Info", "Various status info about an item after it has been imported");
RNA_def_property_enum_funcs(
@@ -518,11 +518,11 @@ static void rna_def_blendfile_import_context(BlenderRNA *brna)
{0, nullptr, 0, nullptr, nullptr},
};
prop = RNA_def_property(srna, "options", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, blend_import_options_items);
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "", "Options for this blendfile import operation");
RNA_def_property_enum_items(prop, blend_import_options_items);
RNA_def_property_enum_funcs(prop, "rna_BlendImportContext_options_get", nullptr, nullptr);
RNA_def_property_ui_text(prop, "", "Options for this blendfile import operation");
/* NOTE: Only stages currently exposed to handlers are listed here. */
static const EnumPropertyItem blend_import_process_stage_items[] = {

View File

@@ -488,9 +488,9 @@ static void rna_def_cloth_solver_result(BlenderRNA *brna)
RNA_define_verify_sdna(false);
prop = RNA_def_property(srna, "status", PROP_ENUM, PROP_NONE);
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_enum_items(prop, status_items);
RNA_def_property_enum_sdna(prop, nullptr, "status");
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Status", "Status of the solver iteration");

View File

@@ -3601,9 +3601,9 @@ static void rna_def_modifier_boolean(BlenderRNA *brna)
};
prop = RNA_def_property(srna, "debug_options", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, debug_items);
RNA_def_property_enum_sdna(prop, nullptr, "bm_flag");
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_enum_sdna(prop, nullptr, "bm_flag");
RNA_def_property_enum_items(prop, debug_items);
RNA_def_property_ui_text(prop, "Debug", "Debugging options, only when started with '-d'");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
@@ -6180,8 +6180,8 @@ static void rna_def_modifier_weightvgproximity(BlenderRNA *brna)
prop = RNA_def_property(srna, "proximity_geometry", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, nullptr, "proximity_flags");
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_enum_items(prop, proximity_geometry_items);
RNA_def_property_flag(prop, PROP_ENUM_FLAG); /* important to run before default set */
RNA_def_property_enum_default(prop, MOD_WVG_PROXIMITY_GEOM_FACES);
RNA_def_property_ui_text(prop,
"Proximity Geometry",

View File

@@ -7991,10 +7991,10 @@ static void def_geo_curve_set_handle_type(BlenderRNA * /*brna*/, StructRNA *srna
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_node_geometry_curve_handle_side_items);
RNA_def_property_ui_text(prop, "Mode", "Whether to update left and right handles");
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_items(prop, rna_enum_node_geometry_curve_handle_side_items);
RNA_def_property_ui_text(prop, "Mode", "Whether to update left and right handles");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
}
@@ -8992,9 +8992,9 @@ static void def_geo_curve_handle_type_selection(BlenderRNA * /*brna*/, StructRNA
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_enum_items(prop, rna_enum_node_geometry_curve_handle_side_items);
RNA_def_property_ui_text(prop, "Mode", "Whether to check the type of left and right handles");
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
}

View File

@@ -3415,9 +3415,9 @@ static void rna_def_property(BlenderRNA *brna)
prop = RNA_def_property(srna, "tags", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
RNA_def_property_enum_items(prop, dummy_prop_tags);
RNA_def_property_enum_funcs(prop, "rna_Property_tags_get", nullptr, "rna_Property_tags_itemf");
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
RNA_def_property_ui_text(
prop, "Tags", "Subset of tags (defined in parent struct) that are set for this property");
}

View File

@@ -3671,32 +3671,29 @@ static void rna_def_tool_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "snap_elements", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, nullptr, "snap_mode");
RNA_def_property_flag(prop, PROP_DEG_SYNC_ONLY);
RNA_def_property_flag(prop, PROP_ENUM_FLAG | PROP_DEG_SYNC_ONLY);
RNA_def_property_enum_items(prop, rna_enum_snap_element_items);
RNA_def_property_enum_funcs(
prop, "rna_ToolSettings_snap_mode_get", "rna_ToolSettings_snap_mode_set", nullptr);
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_ui_text(prop, "Snap Element", "Type of element to snap to");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, nullptr); /* header redraw */
prop = RNA_def_property(srna, "snap_elements_base", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, nullptr, "snap_mode");
RNA_def_property_flag(prop, PROP_DEG_SYNC_ONLY);
RNA_def_property_flag(prop, PROP_ENUM_FLAG | PROP_DEG_SYNC_ONLY);
RNA_def_property_enum_items(prop, rna_enum_snap_element_base_items);
RNA_def_property_enum_funcs(
prop, "rna_ToolSettings_snap_mode_get", "rna_ToolSettings_snap_mode_set", nullptr);
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_ui_text(
prop, "Snap Element", "Type of element for the \"Snap Base\" to snap to");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, nullptr); /* header redraw */
prop = RNA_def_property(srna, "snap_elements_individual", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, nullptr, "snap_mode");
RNA_def_property_flag(prop, PROP_DEG_SYNC_ONLY);
RNA_def_property_flag(prop, PROP_ENUM_FLAG | PROP_DEG_SYNC_ONLY);
RNA_def_property_enum_items(prop, rna_enum_snap_element_individual_items);
RNA_def_property_enum_funcs(
prop, "rna_ToolSettings_snap_mode_get", "rna_ToolSettings_snap_mode_set", nullptr);
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_ui_text(
prop, "Project Mode", "Type of element for individual transformed elements to snap to");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, nullptr); /* header redraw */
@@ -6035,8 +6032,8 @@ static void rna_def_bake_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "pass_filter", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, nullptr, "pass_filter");
RNA_def_property_enum_items(prop, rna_enum_bake_pass_filter_type_items);
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_enum_items(prop, rna_enum_bake_pass_filter_type_items);
RNA_def_property_ui_text(prop, "Pass Filter", "Passes to include in the active baking pass");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
}

View File

@@ -1936,9 +1936,9 @@ static void rna_def_panel(BlenderRNA *brna)
"possible combinations bl_context/bl_region_type/bl_space_type)");
prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
RNA_def_property_enum_sdna(prop, nullptr, "type->flag");
RNA_def_property_enum_items(prop, panel_flag_items);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
RNA_def_property_ui_text(prop, "Options", "Options for this panel type");
prop = RNA_def_property(srna, "bl_parent_id", PROP_STRING, PROP_NONE);
@@ -2288,9 +2288,9 @@ static void rna_def_menu(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
RNA_def_property_enum_sdna(prop, nullptr, "type->flag");
RNA_def_property_enum_items(prop, menu_flag_items);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
RNA_def_property_ui_text(prop, "Options", "Options for this menu type");
RNA_define_verify_sdna(true);
@@ -2351,9 +2351,9 @@ static void rna_def_asset_shelf(BlenderRNA *brna)
prop, "Space Type", "The space where the asset shelf is going to be used in");
prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
RNA_def_property_enum_sdna(prop, nullptr, "type->flag");
RNA_def_property_enum_items(prop, asset_shelf_flag_items);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
RNA_def_property_ui_text(prop, "Options", "Options for this asset shelf type");
prop = RNA_def_property(srna, "bl_activate_operator", PROP_STRING, PROP_NONE);

View File

@@ -5745,9 +5745,9 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
/* keyframing settings */
prop = RNA_def_property(srna, "key_insert_channels", PROP_ENUM, PROP_NONE);
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_enum_bitflag_sdna(prop, nullptr, "key_insert_channels");
RNA_def_property_enum_items(prop, rna_enum_key_insert_channels);
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_ui_text(prop,
"Default Key Channels",
"Which channels to insert keys at when no keying set is active");

View File

@@ -2202,8 +2202,8 @@ static void rna_def_operator_common(StructRNA *srna)
prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, nullptr, "type->flag");
RNA_def_property_enum_items(prop, rna_enum_operator_type_flag_items);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
RNA_def_property_enum_items(prop, rna_enum_operator_type_flag_items);
RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
prop = RNA_def_property(srna, "bl_cursor_pending", PROP_ENUM, PROP_NONE);

View File

@@ -1430,9 +1430,9 @@ static void rna_def_gizmogroup(BlenderRNA *brna)
{0, nullptr, 0, nullptr, nullptr},
};
prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
RNA_def_property_enum_sdna(prop, nullptr, "type->flag");
RNA_def_property_enum_items(prop, gizmogroup_flag_items);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
RNA_define_verify_sdna(true); /* not in sdna */