From f4213c1408619d1071004247ed099e2ba98a3e9a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jul 2018 10:51:49 +0200 Subject: Cleanup: id-property API use Also clarify comments. --- source/blender/blenkernel/intern/idprop.c | 6 +++--- source/blender/editors/interface/interface.c | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index cefd3f5807e..7a526d31567 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -886,7 +886,6 @@ bool IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const bool is case IDP_ID: return (IDP_Id(prop1) == IDP_Id(prop2)); default: - /* should never get here */ BLI_assert(0); break; } @@ -988,7 +987,8 @@ IDProperty *IDP_New(const char type, const IDPropertyTemplate *val, const char * prop->data.pointer = MEM_mallocN(DEFAULT_ALLOC_FOR_NULL_STRINGS, "id property string 1"); *IDP_String(prop) = '\0'; prop->totallen = DEFAULT_ALLOC_FOR_NULL_STRINGS; - prop->len = 1; /*NULL string, has len of 1 to account for null byte.*/ + /* NULL string, has len of 1 to account for null byte. */ + prop->len = 1; } else { BLI_assert((int)val->string.len <= (int)strlen(st) + 1); @@ -1003,8 +1003,8 @@ IDProperty *IDP_New(const char type, const IDPropertyTemplate *val, const char * } case IDP_GROUP: { + /* Values are set properly by calloc. */ prop = MEM_callocN(sizeof(IDProperty), "IDProperty group"); - /* heh I think all needed values are set properly by calloc anyway :) */ break; } case IDP_ID: diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index e51822ac125..82ae4de07af 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1004,14 +1004,12 @@ static bool ui_but_event_operator_string_from_menu( BLI_assert(mt != NULL); bool found = false; - IDProperty *prop_menu, *prop_menu_name; + IDProperty *prop_menu; /* annoying, create a property */ IDPropertyTemplate val = {0}; prop_menu = IDP_New(IDP_GROUP, &val, __func__); /* dummy, name is unimportant */ - IDP_AddToGroup(prop_menu, (prop_menu_name = IDP_NewString("", "name", sizeof(mt->idname)))); - - IDP_AssignString(prop_menu_name, mt->idname, sizeof(mt->idname)); + IDP_AddToGroup(prop_menu, IDP_NewString(mt->idname, "name", sizeof(mt->idname))); if (WM_key_event_operator_string( C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, true, -- cgit v1.2.3