UI: Warn when using fallback category
Scripts should be updated.
This commit is contained in:
		@@ -1534,6 +1534,12 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
 | 
			
		||||
 | 
			
		||||
		const bool is_active = STREQ(category_id, category_id_active);
 | 
			
		||||
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
		if (STREQ(category_id, PNL_CATEGORY_FALLBACK)) {
 | 
			
		||||
			printf("WARNING: Panel has no 'bl_category', script needs updating!\n");
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
		glEnable(GL_BLEND);
 | 
			
		||||
 | 
			
		||||
#ifdef USE_FLAT_INACTIVE
 | 
			
		||||
 
 | 
			
		||||
@@ -315,8 +315,8 @@ enum {
 | 
			
		||||
#define PNL_DEFAULT_CLOSED		1
 | 
			
		||||
#define PNL_NO_HEADER			2
 | 
			
		||||
 | 
			
		||||
/* Default panel category. */
 | 
			
		||||
#define PNL_DEFAULT_CATEGORY "Misc"
 | 
			
		||||
/* Fallback panel category (only for old scripts which need updating) */
 | 
			
		||||
#define PNL_CATEGORY_FALLBACK "Misc"
 | 
			
		||||
 | 
			
		||||
/* uiList layout_type */
 | 
			
		||||
enum {
 | 
			
		||||
 
 | 
			
		||||
@@ -201,9 +201,6 @@ static StructRNA *rna_Panel_register(Main *bmain, ReportList *reports, void *dat
 | 
			
		||||
	/* We have to set default context! Else we get a void string... */
 | 
			
		||||
	strcpy(dummypt.translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA);
 | 
			
		||||
 | 
			
		||||
	/* We have to set default category! Else we get a void string, and panel goes everywhere! */
 | 
			
		||||
	strcpy(dummypt.category, PNL_DEFAULT_CATEGORY);
 | 
			
		||||
 | 
			
		||||
	/* validate the python class */
 | 
			
		||||
	if (validate(&dummyptr, data, have_function) != 0)
 | 
			
		||||
		return NULL;
 | 
			
		||||
@@ -214,6 +211,11 @@ static StructRNA *rna_Panel_register(Main *bmain, ReportList *reports, void *dat
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ((dummypt.category[0] == '\0') && (dummypt.region_type == RGN_TYPE_TOOLS)) {
 | 
			
		||||
		/* Use a fallback, otherwise an empty value will draw the panel in every category. */
 | 
			
		||||
		strcpy(dummypt.category, PNL_CATEGORY_FALLBACK);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (!(art = region_type_find(reports, dummypt.space_type, dummypt.region_type)))
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
@@ -990,7 +992,6 @@ static void rna_def_panel(BlenderRNA *brna)
 | 
			
		||||
 | 
			
		||||
	prop = RNA_def_property(srna, "bl_category", PROP_STRING, PROP_NONE);
 | 
			
		||||
	RNA_def_property_string_sdna(prop, NULL, "type->category");
 | 
			
		||||
	RNA_def_property_string_default(prop, PNL_DEFAULT_CATEGORY);
 | 
			
		||||
	RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
 | 
			
		||||
 | 
			
		||||
	prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user