forked from bartvdbraak/blender
Make list_id mandatory when using default UI_UL_list class for a template_list.
This commit is contained in:
parent
b187d33751
commit
d7058f12e5
@ -137,6 +137,7 @@ def unregister():
|
||||
|
||||
|
||||
# Define a default UIList, when a list does not need any custom drawing...
|
||||
# Keep in sync with its #defined name in UI_interface.h
|
||||
class UI_UL_list(bpy.types.UIList):
|
||||
pass
|
||||
|
||||
|
@ -832,6 +832,8 @@ void uiTemplateTextureImage(uiLayout *layout, struct bContext *C, struct Tex *te
|
||||
void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
|
||||
void uiTemplateKeymapItemProperties(uiLayout *layout, struct PointerRNA *ptr);
|
||||
|
||||
/* Default UIList class name, keep in sync with its declaration in bl_ui/__init__.py */
|
||||
#define UI_UL_DEFAULT_CLASS_NAME "UI_UL_list"
|
||||
void uiTemplateList(uiLayout *layout, struct bContext *C, const char *listtype_name, const char *list_id,
|
||||
struct PointerRNA *dataptr, const char *propname, struct PointerRNA *active_dataptr,
|
||||
const char *active_propname, int rows, int maxrows, int layout_type);
|
||||
|
@ -2478,6 +2478,13 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
|
||||
int min, max;
|
||||
|
||||
/* validate arguments */
|
||||
/* Forbid default UI_UL_DEFAULT_CLASS_NAME list class without a custom list_id! */
|
||||
if (!strcmp(UI_UL_DEFAULT_CLASS_NAME, listtype_name) && !(list_id && list_id[0])) {
|
||||
RNA_warning("template_list using default '" UI_UL_DEFAULT_CLASS_NAME
|
||||
"' UIList class must provide a custom list_id");
|
||||
return;
|
||||
}
|
||||
|
||||
block = uiLayoutGetBlock(layout);
|
||||
|
||||
if (!active_dataptr->data) {
|
||||
|
@ -771,8 +771,8 @@ void RNA_api_ui_layout(StructRNA *srna)
|
||||
parm = RNA_def_string(func, "listtype_name", "", 0, "", "Identifier of the list type to use");
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
parm = RNA_def_string(func, "list_id", "", 0, "",
|
||||
"Identifier of this list widget (should be systematically used with default UI_UL_list "
|
||||
"class). "
|
||||
"Identifier of this list widget (mandatory when using default \"" UI_UL_DEFAULT_CLASS_NAME
|
||||
"\" class). "
|
||||
"If this is set, the uilist gets a custom ID, otherwise it takes the "
|
||||
"name of the class used to define the uilist (for example, if the "
|
||||
"class name is \"OBJECT_UL_vgroups\", and list_id is not set by the "
|
||||
|
Loading…
Reference in New Issue
Block a user