WM: enforce descriptions being NULL or defined
Without this bugs slip through that don't null check the descriptions since many were set to empty strings.
This commit is contained in:
@@ -1979,7 +1979,9 @@ void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon)
|
||||
if (layout->root->type == UI_LAYOUT_MENU && !icon)
|
||||
icon = ICON_BLANK1;
|
||||
|
||||
ui_item_menu(layout, name, icon, ui_item_menutype_func, mt, NULL, TIP_(mt->description), false);
|
||||
ui_item_menu(
|
||||
layout, name, icon, ui_item_menutype_func, mt, NULL,
|
||||
mt->description ? TIP_(mt->description) : "", false);
|
||||
}
|
||||
|
||||
/* label item */
|
||||
|
||||
@@ -1545,7 +1545,6 @@ static void VIEW2D_OT_smoothview(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Smooth View 2D";
|
||||
ot->description = "";
|
||||
ot->idname = "VIEW2D_OT_smoothview";
|
||||
|
||||
/* api callbacks */
|
||||
|
||||
@@ -88,7 +88,6 @@ void MASK_OT_shape_key_insert(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Insert Shape Key";
|
||||
ot->description = "";
|
||||
ot->idname = "MASK_OT_shape_key_insert";
|
||||
|
||||
/* api callbacks */
|
||||
@@ -137,7 +136,6 @@ void MASK_OT_shape_key_clear(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Clear Shape Key";
|
||||
ot->description = "";
|
||||
ot->idname = "MASK_OT_shape_key_clear";
|
||||
|
||||
/* api callbacks */
|
||||
|
||||
@@ -247,7 +247,6 @@ void MESH_OT_subdivide_edgering(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Subdivide Edge-Ring";
|
||||
ot->description = "";
|
||||
ot->idname = "MESH_OT_subdivide_edgering";
|
||||
|
||||
/* api callbacks */
|
||||
|
||||
@@ -2501,7 +2501,6 @@ void OBJECT_OT_drop_named_material(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Drop Named Material on Object";
|
||||
ot->description = "";
|
||||
ot->idname = "OBJECT_OT_drop_named_material";
|
||||
|
||||
/* api callbacks */
|
||||
@@ -2558,7 +2557,6 @@ void OBJECT_OT_unlink_data(wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Unlink";
|
||||
ot->idname = "OBJECT_OT_unlink_data";
|
||||
ot->description = "";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = object_unlink_data_exec;
|
||||
|
||||
@@ -1714,7 +1714,6 @@ static int filepath_drop_exec(bContext *C, wmOperator *op)
|
||||
void FILE_OT_filepath_drop(wmOperatorType *ot)
|
||||
{
|
||||
ot->name = "File Selector Drop";
|
||||
ot->description = "";
|
||||
ot->idname = "FILE_OT_filepath_drop";
|
||||
|
||||
ot->exec = filepath_drop_exec;
|
||||
|
||||
@@ -509,7 +509,6 @@ void OUTLINER_OT_id_remap(wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Outliner ID data Remap";
|
||||
ot->idname = "OUTLINER_OT_id_remap";
|
||||
ot->description = "";
|
||||
|
||||
/* callbacks */
|
||||
ot->invoke = outliner_id_remap_invoke;
|
||||
|
||||
@@ -1025,7 +1025,6 @@ void OUTLINER_OT_object_operation(wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Outliner Object Operation";
|
||||
ot->idname = "OUTLINER_OT_object_operation";
|
||||
ot->description = "";
|
||||
|
||||
/* callbacks */
|
||||
ot->invoke = WM_menu_invoke;
|
||||
@@ -1128,7 +1127,6 @@ void OUTLINER_OT_group_operation(wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Outliner Group Operation";
|
||||
ot->idname = "OUTLINER_OT_group_operation";
|
||||
ot->description = "";
|
||||
|
||||
/* callbacks */
|
||||
ot->invoke = WM_menu_invoke;
|
||||
@@ -1323,7 +1321,6 @@ void OUTLINER_OT_id_operation(wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Outliner ID data Operation";
|
||||
ot->idname = "OUTLINER_OT_id_operation";
|
||||
ot->description = "";
|
||||
|
||||
/* callbacks */
|
||||
ot->invoke = WM_menu_invoke;
|
||||
@@ -1418,7 +1415,6 @@ void OUTLINER_OT_lib_operation(wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Outliner Library Operation";
|
||||
ot->idname = "OUTLINER_OT_lib_operation";
|
||||
ot->description = "";
|
||||
|
||||
/* callbacks */
|
||||
ot->invoke = WM_menu_invoke;
|
||||
@@ -1642,7 +1638,6 @@ void OUTLINER_OT_animdata_operation(wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Outliner Animation Data Operation";
|
||||
ot->idname = "OUTLINER_OT_animdata_operation";
|
||||
ot->description = "";
|
||||
|
||||
/* callbacks */
|
||||
ot->invoke = WM_menu_invoke;
|
||||
@@ -1688,7 +1683,6 @@ void OUTLINER_OT_constraint_operation(wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Outliner Constraint Operation";
|
||||
ot->idname = "OUTLINER_OT_constraint_operation";
|
||||
ot->description = "";
|
||||
|
||||
/* callbacks */
|
||||
ot->invoke = WM_menu_invoke;
|
||||
@@ -1734,7 +1728,6 @@ void OUTLINER_OT_modifier_operation(wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Outliner Modifier Operation";
|
||||
ot->idname = "OUTLINER_OT_modifier_operation";
|
||||
ot->description = "";
|
||||
|
||||
/* callbacks */
|
||||
ot->invoke = WM_menu_invoke;
|
||||
@@ -1832,7 +1825,6 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Outliner Data Operation";
|
||||
ot->idname = "OUTLINER_OT_data_operation";
|
||||
ot->description = "";
|
||||
|
||||
/* callbacks */
|
||||
ot->invoke = WM_menu_invoke;
|
||||
|
||||
@@ -3288,7 +3288,6 @@ void SEQUENCER_OT_copy(wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Copy";
|
||||
ot->idname = "SEQUENCER_OT_copy";
|
||||
ot->description = "";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = sequencer_copy_exec;
|
||||
@@ -3353,7 +3352,6 @@ void SEQUENCER_OT_paste(wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Paste";
|
||||
ot->idname = "SEQUENCER_OT_paste";
|
||||
ot->description = "";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = sequencer_paste_exec;
|
||||
@@ -3683,7 +3681,6 @@ void SEQUENCER_OT_change_effect_input(struct wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Change Effect Input";
|
||||
ot->idname = "SEQUENCER_OT_change_effect_input";
|
||||
ot->description = "";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = sequencer_change_effect_input_exec;
|
||||
@@ -3743,7 +3740,6 @@ void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Change Effect Type";
|
||||
ot->idname = "SEQUENCER_OT_change_effect_type";
|
||||
ot->description = "";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = sequencer_change_effect_type_exec;
|
||||
@@ -3878,7 +3874,6 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot)
|
||||
/* identifiers */
|
||||
ot->name = "Change Data/Files";
|
||||
ot->idname = "SEQUENCER_OT_change_path";
|
||||
ot->description = "";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = sequencer_change_path_exec;
|
||||
|
||||
@@ -2305,7 +2305,6 @@ void TEXT_OT_scroll(wmOperatorType *ot)
|
||||
* scroll_bar. Both do basically the same thing (aside
|
||||
* from keymaps).*/
|
||||
ot->idname = "TEXT_OT_scroll";
|
||||
ot->description = "";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = text_scroll_exec;
|
||||
@@ -2397,7 +2396,6 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot)
|
||||
* scroll. Both do basically the same thing (aside
|
||||
* from keymaps).*/
|
||||
ot->idname = "TEXT_OT_scroll_bar";
|
||||
ot->description = "";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke = text_scroll_bar_invoke;
|
||||
|
||||
@@ -414,7 +414,6 @@ void VIEW3D_OT_smoothview(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Smooth View";
|
||||
ot->description = "";
|
||||
ot->idname = "VIEW3D_OT_smoothview";
|
||||
|
||||
/* api callbacks */
|
||||
|
||||
@@ -759,8 +759,9 @@ static StructRNA *rna_Menu_register(
|
||||
memcpy(buf, _menu_descr, description_size);
|
||||
mt->description = buf;
|
||||
}
|
||||
else
|
||||
mt->description = "";
|
||||
else {
|
||||
mt->description = NULL;
|
||||
}
|
||||
|
||||
mt->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, mt->idname, &RNA_Menu);
|
||||
RNA_def_struct_translation_context(mt->ext.srna, mt->translation_context);
|
||||
|
||||
@@ -1187,7 +1187,7 @@ static StructRNA *rna_Operator_register(
|
||||
|
||||
dummyot.idname = strings_table[0]; /* allocated string stored here */
|
||||
dummyot.name = strings_table[1];
|
||||
dummyot.description = strings_table[2];
|
||||
dummyot.description = *strings_table[2] ? strings_table[2] : NULL;
|
||||
dummyot.translation_context = strings_table[3];
|
||||
dummyot.undo_group = strings_table[4];
|
||||
BLI_assert(ARRAY_SIZE(strings) == 5);
|
||||
@@ -1328,7 +1328,7 @@ static StructRNA *rna_MacroOperator_register(
|
||||
|
||||
dummyot.idname = strings_table[0]; /* allocated string stored here */
|
||||
dummyot.name = strings_table[1];
|
||||
dummyot.description = strings_table[2];
|
||||
dummyot.description = *strings_table[2] ? strings_table[2] : NULL;
|
||||
dummyot.translation_context = strings_table[3];
|
||||
dummyot.undo_group = strings_table[4];
|
||||
BLI_assert(ARRAY_SIZE(strings) == 5);
|
||||
|
||||
@@ -60,6 +60,7 @@ MenuType *WM_menutype_find(const char *idname, bool quiet)
|
||||
|
||||
bool WM_menutype_add(MenuType *mt)
|
||||
{
|
||||
BLI_assert((mt->description == NULL) || (mt->description[0]));
|
||||
BLI_ghash_insert(menutypes_hash, mt->idname, mt);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@ void WM_operatortype_append(void (*opfunc)(wmOperatorType *))
|
||||
if (ot->name == NULL) {
|
||||
CLOG_ERROR(WM_LOG_OPERATORS, "Operator '%s' has no name property", ot->idname);
|
||||
}
|
||||
BLI_assert((ot->description == NULL) || (ot->description[0]));
|
||||
|
||||
/* XXX All ops should have a description but for now allow them not to. */
|
||||
RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP);
|
||||
@@ -134,6 +135,7 @@ void WM_operatortype_append_ptr(void (*opfunc)(wmOperatorType *, void *), void *
|
||||
RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
|
||||
ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT;
|
||||
opfunc(ot, userdata);
|
||||
BLI_assert((ot->description == NULL) || (ot->description[0]));
|
||||
RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP);
|
||||
RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user