diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-26 07:05:07 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-26 07:05:07 +0300 |
commit | 6be7a98906b769c1496127552b524124a0e70c5a (patch) | |
tree | 9b20ec2147c656e815adb4688045acbb5af3e074 /source/blender/makesrna/intern/rna_ui.c | |
parent | 4c75cc488a49ff9dedf9b0aa520f8688d753b987 (diff) |
PyAPI: raise error when toolbar panels use tabs
Add-ons that register panels in the toolbar can
no longer use 'bl_categories' (tabs).
Diffstat (limited to 'source/blender/makesrna/intern/rna_ui.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_ui.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 0756d5e39ee..9d395f3ec9b 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -28,6 +28,7 @@ #include <stdlib.h> #include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "BLT_translation.h" @@ -41,6 +42,7 @@ #include "UI_interface.h" #include "WM_types.h" +#include "WM_toolsystem.h" /* see WM_types.h */ const EnumPropertyItem rna_enum_operator_context_items[] = { @@ -243,9 +245,20 @@ static StructRNA *rna_Panel_register( 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 ((1 << dummypt.region_type) & RGN_TYPE_HAS_CATEGORY_MASK) { + if (dummypt.category[0] == '\0') { + /* Use a fallback, otherwise an empty value will draw the panel in every category. */ + strcpy(dummypt.category, PNL_CATEGORY_FALLBACK); + } + } + else { + if (dummypt.category[0] != '\0') { + if ((1 << dummypt.space_type) & WM_TOOLSYSTEM_SPACE_MASK) { + BKE_reportf(reports, RPT_ERROR, "Registering panel class: '%s' has category '%s' ", + dummypt.idname, dummypt.category); + return NULL; + } + } } if (!(art = region_type_find(reports, dummypt.space_type, dummypt.region_type))) |