Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesrna/intern/rna_ui.c')
-rw-r--r--source/blender/makesrna/intern/rna_ui.c108
1 files changed, 70 insertions, 38 deletions
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index 5f11dd51282..08038b0b1ff 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -177,16 +177,17 @@ static void rna_Panel_unregister(Main *UNUSED(bmain), StructRNA *type)
return;
RNA_struct_free_extension(type, &pt->ext);
+ RNA_struct_free(&BLENDER_RNA, type);
BLI_freelinkN(&art->paneltypes, pt);
- RNA_struct_free(&BLENDER_RNA, type);
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
}
-static StructRNA *rna_Panel_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
- StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_Panel_register(
+ Main *bmain, ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
ARegionType *art;
PanelType *pt, dummypt = {NULL};
@@ -229,6 +230,12 @@ static StructRNA *rna_Panel_register(Main *bmain, ReportList *reports, void *dat
break;
}
}
+ if (!RNA_struct_available_or_report(reports, dummypt.idname)) {
+ return NULL;
+ }
+ if (!RNA_struct_bl_idname_ok_or_report(reports, dummypt.idname, "_PT_")) {
+ return NULL;
+ }
/* create a new panel type */
pt = MEM_callocN(sizeof(PanelType), "python buttons panel");
@@ -455,17 +462,17 @@ static void rna_UIList_unregister(Main *UNUSED(bmain), StructRNA *type)
return;
RNA_struct_free_extension(type, &ult->ext);
+ RNA_struct_free(&BLENDER_RNA, type);
WM_uilisttype_freelink(ult);
- RNA_struct_free(&BLENDER_RNA, type);
-
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
}
-static StructRNA *rna_UIList_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
- StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_UIList_register(
+ Main *bmain, ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
uiListType *ult, dummyult = {NULL};
uiList dummyuilist = {NULL};
@@ -489,8 +496,15 @@ static StructRNA *rna_UIList_register(Main *bmain, ReportList *reports, void *da
/* check if we have registered this uilist type before, and remove it */
ult = WM_uilisttype_find(dummyult.idname, true);
- if (ult && ult->ext.srna)
+ if (ult && ult->ext.srna) {
rna_UIList_unregister(bmain, ult->ext.srna);
+ }
+ if (!RNA_struct_available_or_report(reports, dummyult.idname)) {
+ return NULL;
+ }
+ if (!RNA_struct_bl_idname_ok_or_report(reports, dummyult.idname, "_UL_")) {
+ return NULL;
+ }
/* create a new menu type */
ult = MEM_callocN(sizeof(uiListType) + over_alloc, "python uilist");
@@ -551,16 +565,17 @@ static void rna_Header_unregister(Main *UNUSED(bmain), StructRNA *type)
return;
RNA_struct_free_extension(type, &ht->ext);
+ RNA_struct_free(&BLENDER_RNA, type);
BLI_freelinkN(&art->headertypes, ht);
- RNA_struct_free(&BLENDER_RNA, type);
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
}
-static StructRNA *rna_Header_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
- StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_Header_register(
+ Main *bmain, ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
ARegionType *art;
HeaderType *ht, dummyht = {NULL};
@@ -593,6 +608,12 @@ static StructRNA *rna_Header_register(Main *bmain, ReportList *reports, void *da
break;
}
}
+ if (!RNA_struct_available_or_report(reports, dummyht.idname)) {
+ return NULL;
+ }
+ if (!RNA_struct_bl_idname_ok_or_report(reports, dummyht.idname, "_HT_")) {
+ return NULL;
+ }
/* create a new header type */
ht = MEM_callocN(sizeof(HeaderType), "python buttons header");
@@ -673,17 +694,17 @@ static void rna_Menu_unregister(Main *UNUSED(bmain), StructRNA *type)
return;
RNA_struct_free_extension(type, &mt->ext);
+ RNA_struct_free(&BLENDER_RNA, type);
WM_menutype_freelink(mt);
- RNA_struct_free(&BLENDER_RNA, type);
-
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
}
-static StructRNA *rna_Menu_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
- StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+static StructRNA *rna_Menu_register(
+ Main *bmain, ReportList *reports, void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
{
MenuType *mt, dummymt = {NULL};
Menu dummymenu = {NULL};
@@ -714,8 +735,15 @@ static StructRNA *rna_Menu_register(Main *bmain, ReportList *reports, void *data
/* check if we have registered this menu type before, and remove it */
mt = WM_menutype_find(dummymt.idname, true);
- if (mt && mt->ext.srna)
+ if (mt && mt->ext.srna) {
rna_Menu_unregister(bmain, mt->ext.srna);
+ }
+ if (!RNA_struct_available_or_report(reports, dummymt.idname)) {
+ return NULL;
+ }
+ if (!RNA_struct_bl_idname_ok_or_report(reports, dummymt.idname, "_MT_")) {
+ return NULL;
+ }
/* create a new menu type */
if (_menu_descr[0]) {
@@ -937,6 +965,7 @@ static void rna_def_panel(BlenderRNA *brna)
RNA_def_struct_refine_func(srna, "rna_Panel_refine");
RNA_def_struct_register_funcs(srna, "rna_Panel_register", "rna_Panel_unregister", NULL);
RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+ RNA_def_struct_flag(srna, STRUCT_PUBLIC_NAMESPACE_INHERIT);
/* poll */
func = RNA_def_function(srna, "poll", NULL);
@@ -944,20 +973,20 @@ static void rna_def_panel(BlenderRNA *brna)
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
/* draw */
func = RNA_def_function(srna, "draw", NULL);
RNA_def_function_ui_description(func, "Draw UI elements into the panel UI layout");
RNA_def_function_flag(func, FUNC_REGISTER);
parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
func = RNA_def_function(srna, "draw_header", NULL);
RNA_def_function_ui_description(func, "Draw UI elements into the panel's header UI layout");
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "UILayout");
@@ -1039,6 +1068,7 @@ static void rna_def_uilist(BlenderRNA *brna)
RNA_def_struct_refine_func(srna, "rna_UIList_refine");
RNA_def_struct_register_funcs(srna, "rna_UIList_register", "rna_UIList_unregister", NULL);
RNA_def_struct_idprops_func(srna, "rna_UIList_idprops");
+ RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES | STRUCT_PUBLIC_NAMESPACE_INHERIT);
/* Registration */
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
@@ -1084,35 +1114,35 @@ static void rna_def_uilist(BlenderRNA *brna)
"function, you may want to check given 'item' is of the right type...)");
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Layout to draw the item");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take Collection property");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR);
parm = RNA_def_pointer(func, "item", "AnyType", "", "Item of the collection property");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR);
parm = RNA_def_int(func, "icon", 0, 0, INT_MAX, "", "Icon of the item in the collection", 0, INT_MAX);
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_pointer(func, "active_data", "AnyType", "",
"Data from which to take property for the active element");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
parm = RNA_def_string(func, "active_property", NULL, 0, "",
"Identifier of property in active_data, for the active element");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_def_int(func, "index", 0, 0, INT_MAX, "", "Index of the item in the collection", 0, INT_MAX);
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_PYFUNC_OPTIONAL);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_PYFUNC_OPTIONAL);
prop = RNA_def_property(func, "flt_flag", PROP_INT, PROP_UNSIGNED);
RNA_def_property_ui_text(prop, "", "The filter-flag result for this item");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_PYFUNC_OPTIONAL);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_PYFUNC_OPTIONAL);
/* draw_filter */
func = RNA_def_function(srna, "draw_filter", NULL);
RNA_def_function_ui_description(func, "Draw filtering options");
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Layout to draw the item");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
/* filter */
func = RNA_def_function(srna, "filter_items", NULL);
@@ -1120,19 +1150,19 @@ static void rna_def_uilist(BlenderRNA *brna)
"filter_flags, and reorder results in filter_neworder arrays)");
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take Collection property");
- RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR);
parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in data, for the collection");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
prop = RNA_def_property(func, "filter_flags", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_flag(prop, PROP_REQUIRED | PROP_DYNAMIC);
+ RNA_def_property_flag(prop, PARM_REQUIRED | PROP_DYNAMIC);
RNA_def_property_array(prop, 1); /* XXX Dummy value, default 0 does not work */
RNA_def_property_ui_text(prop, "", "An array of filter flags, one for each item in the collection (NOTE: "
"FILTER_ITEM bit is reserved, it defines whether the item is shown or not)");
RNA_def_function_output(func, prop);
prop = RNA_def_property(func, "filter_neworder", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_flag(prop, PROP_REQUIRED | PROP_DYNAMIC);
+ RNA_def_property_flag(prop, PARM_REQUIRED | PROP_DYNAMIC);
RNA_def_property_array(prop, 1); /* XXX Dummy value, default 0 does not work */
RNA_def_property_ui_text(prop, "", "An array of indices, one for each item in the collection, mapping the org "
"index to the new one");
@@ -1160,13 +1190,14 @@ static void rna_def_header(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "Header");
RNA_def_struct_refine_func(srna, "rna_Header_refine");
RNA_def_struct_register_funcs(srna, "rna_Header_register", "rna_Header_unregister", NULL);
+ RNA_def_struct_flag(srna, STRUCT_PUBLIC_NAMESPACE_INHERIT);
/* draw */
func = RNA_def_function(srna, "draw", NULL);
RNA_def_function_ui_description(func, "Draw UI elements into the header UI layout");
RNA_def_function_flag(func, FUNC_REGISTER);
parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_define_verify_sdna(0); /* not in sdna */
@@ -1207,6 +1238,7 @@ static void rna_def_menu(BlenderRNA *brna)
RNA_def_struct_refine_func(srna, "rna_Menu_refine");
RNA_def_struct_register_funcs(srna, "rna_Menu_register", "rna_Menu_unregister", NULL);
RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+ RNA_def_struct_flag(srna, STRUCT_PUBLIC_NAMESPACE_INHERIT);
/* poll */
func = RNA_def_function(srna, "poll", NULL);
@@ -1214,14 +1246,14 @@ static void rna_def_menu(BlenderRNA *brna)
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
/* draw */
func = RNA_def_function(srna, "draw", NULL);
RNA_def_function_ui_description(func, "Draw UI elements into the menu UI layout");
RNA_def_function_flag(func, FUNC_REGISTER);
parm = RNA_def_pointer(func, "context", "Context", "", "");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
RNA_define_verify_sdna(false); /* not in sdna */