#70267 Retopology Overlay #104599

Merged
Clément Foucault merged 30 commits from bonj/blender:retopology-overlay into main 2023-03-03 00:35:56 +01:00
10 changed files with 264 additions and 91 deletions
Showing only changes of commit bae2564702 - Show all commits

View File

@ -748,8 +748,8 @@ typedef struct StructRNA *(*StructRegisterFunc)(struct Main *bmain,
StructValidateFunc validate,
StructCallbackFunc call,
StructFreeFunc free);
typedef void (*StructUnregisterFunc)(struct Main *bmain, struct StructRNA *type);
/** Return true when `type` was successfully unregistered & freed. */
typedef bool (*StructUnregisterFunc)(struct Main *bmain, struct StructRNA *type);
typedef void **(*StructInstanceFunc)(PointerRNA *ptr);
typedef struct StructRNA StructRNA;

View File

@ -630,9 +630,10 @@ IDProperty **rna_PropertyGroup_idprops(PointerRNA *ptr)
return (IDProperty **)&ptr->data;
}
void rna_PropertyGroup_unregister(Main *UNUSED(bmain), StructRNA *type)
bool rna_PropertyGroup_unregister(Main *UNUSED(bmain), StructRNA *type)
{
RNA_struct_free(&BLENDER_RNA, type);
return true;
}
StructRNA *rna_PropertyGroup_register(Main *UNUSED(bmain),

View File

@ -255,12 +255,12 @@ static StructRNA *rna_KeyingSetInfo_refine(PointerRNA *ptr)
return (ksi->rna_ext.srna) ? ksi->rna_ext.srna : &RNA_KeyingSetInfo;
}
static void rna_KeyingSetInfo_unregister(Main *bmain, StructRNA *type)
static bool rna_KeyingSetInfo_unregister(Main *bmain, StructRNA *type)
{
KeyingSetInfo *ksi = RNA_struct_blender_type_get(type);
if (ksi == NULL) {
return;
return false;
}
/* free RNA data referencing this */
@ -271,6 +271,7 @@ static void rna_KeyingSetInfo_unregister(Main *bmain, StructRNA *type)
/* unlink Blender-side data */
ANIM_keyingset_info_unregister(bmain, ksi);
return true;
}
static StructRNA *rna_KeyingSetInfo_register(Main *bmain,
@ -281,6 +282,7 @@ static StructRNA *rna_KeyingSetInfo_register(Main *bmain,
StructCallbackFunc call,
StructFreeFunc free)
{
const char *error_prefix = "Registering keying set info class:";
KeyingSetInfo dummyksi = {NULL};
KeyingSetInfo *ksi;
PointerRNA dummyptr = {NULL};
@ -299,7 +301,8 @@ static StructRNA *rna_KeyingSetInfo_register(Main *bmain,
if (strlen(identifier) >= sizeof(dummyksi.idname)) {
BKE_reportf(reports,
RPT_ERROR,
"Registering keying set info class: '%s' is too long, maximum length is %d",
"%s '%s' is too long, maximum length is %d",
error_prefix,
identifier,
(int)sizeof(dummyksi.idname));
return NULL;
@ -307,8 +310,18 @@ static StructRNA *rna_KeyingSetInfo_register(Main *bmain,
/* check if we have registered this info before, and remove it */
ksi = ANIM_keyingset_info_find_name(dummyksi.idname);
if (ksi && ksi->rna_ext.srna) {
rna_KeyingSetInfo_unregister(bmain, ksi->rna_ext.srna);
if (ksi) {
StructRNA *srna = ksi->rna_ext.srna;
if (!(srna && rna_KeyingSetInfo_unregister(bmain, srna))) {
BKE_reportf(reports,
RPT_ERROR,
"%s '%s', bl_idname '%s' %s",
error_prefix,
identifier,
dummyksi.idname,
srna ? "is built-in" : "could not be unregistered");
return NULL;
}
}
/* create a new KeyingSetInfo type */

View File

@ -292,7 +292,7 @@ struct IDProperty **rna_ID_idprops(struct PointerRNA *ptr);
void rna_ID_fake_user_set(struct PointerRNA *ptr, bool value);
void **rna_ID_instance(PointerRNA *ptr);
struct IDProperty **rna_PropertyGroup_idprops(struct PointerRNA *ptr);
void rna_PropertyGroup_unregister(struct Main *bmain, struct StructRNA *type);
bool rna_PropertyGroup_unregister(struct Main *bmain, struct StructRNA *type);
struct StructRNA *rna_PropertyGroup_register(struct Main *bmain,
struct ReportList *reports,
void *data,

View File

@ -1046,12 +1046,12 @@ static bool rna_NodeTree_valid_socket_type(bNodeTreeType *ntreetype, bNodeSocket
return valid;
}
static void rna_NodeTree_unregister(Main *UNUSED(bmain), StructRNA *type)
static bool rna_NodeTree_unregister(Main *UNUSED(bmain), StructRNA *type)
{
bNodeTreeType *nt = RNA_struct_blender_type_get(type);
if (!nt) {
return;
return false;
}
RNA_struct_free_extension(type, &nt->rna_ext);
@ -1061,6 +1061,7 @@ static void rna_NodeTree_unregister(Main *UNUSED(bmain), StructRNA *type)
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
return true;
}
static StructRNA *rna_NodeTree_register(Main *bmain,
@ -1071,6 +1072,7 @@ static StructRNA *rna_NodeTree_register(Main *bmain,
StructCallbackFunc call,
StructFreeFunc free)
{
const char *error_prefix = "Registering node tree class:";
bNodeTreeType *nt, dummynt;
bNodeTree dummyntree;
PointerRNA dummyptr;
@ -1090,7 +1092,8 @@ static StructRNA *rna_NodeTree_register(Main *bmain,
if (strlen(identifier) >= sizeof(dummynt.idname)) {
BKE_reportf(reports,
RPT_ERROR,
"Registering node tree class: '%s' is too long, maximum length is %d",
"%s '%s' is too long, maximum length is %d",
error_prefix,
identifier,
(int)sizeof(dummynt.idname));
return NULL;
@ -1099,7 +1102,16 @@ static StructRNA *rna_NodeTree_register(Main *bmain,
/* check if we have registered this tree type before, and remove it */
nt = ntreeTypeFind(dummynt.idname);
if (nt) {
rna_NodeTree_unregister(bmain, nt->rna_ext.srna);
/* NOTE: unlike most types `nt->rna_ext.srna` doesn't need to be checked for NULL. */
if (!rna_NodeTree_unregister(bmain, nt->rna_ext.srna)) {
BKE_reportf(reports,
RPT_ERROR,
"%s '%s', bl_idname '%s' could not be unregistered",
error_prefix,
identifier,
dummynt.idname);
return NULL;
}
}
/* create a new node tree type */
@ -1884,12 +1896,12 @@ static void rna_Node_is_registered_node_type_runtime(bContext *UNUSED(C),
RNA_parameter_set_lookup(parms, "result", &result);
}
static void rna_Node_unregister(Main *UNUSED(bmain), StructRNA *type)
static bool rna_Node_unregister(Main *UNUSED(bmain), StructRNA *type)
{
bNodeType *nt = RNA_struct_blender_type_get(type);
if (!nt) {
return;
return false;
}
RNA_struct_free_extension(type, &nt->rna_ext);
@ -1900,6 +1912,7 @@ static void rna_Node_unregister(Main *UNUSED(bmain), StructRNA *type)
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
return true;
}
/* Generic internal registration function.
@ -1914,6 +1927,7 @@ static bNodeType *rna_Node_register_base(Main *bmain,
StructCallbackFunc call,
StructFreeFunc free)
{
const char *error_prefix = "Registering node class:";
bNodeType *nt, dummynt;
bNode dummynode;
PointerRNA dummyptr;
@ -1938,7 +1952,8 @@ static bNodeType *rna_Node_register_base(Main *bmain,
if (strlen(identifier) >= sizeof(dummynt.idname)) {
BKE_reportf(reports,
RPT_ERROR,
"Registering node class: '%s' is too long, maximum length is %d",
"%s '%s' is too long, maximum length is %d",
error_prefix,
identifier,
(int)sizeof(dummynt.idname));
return NULL;
@ -1947,7 +1962,16 @@ static bNodeType *rna_Node_register_base(Main *bmain,
/* check if we have registered this node type before, and remove it */
nt = nodeTypeFind(dummynt.idname);
if (nt) {
rna_Node_unregister(bmain, nt->rna_ext.srna);
/* NOTE: unlike most types `nt->rna_ext.srna` doesn't need to be checked for NULL. */
if (!rna_Node_unregister(bmain, nt->rna_ext.srna)) {
BKE_reportf(reports,
RPT_ERROR,
"%s '%s', bl_idname '%s' could not be unregistered",
error_prefix,
identifier,
dummynt.idname);
return NULL;
}
}
/* create a new node type */
@ -2725,11 +2749,11 @@ static void rna_NodeSocket_draw_color(bContext *C,
RNA_parameter_list_free(&list);
}
static void rna_NodeSocket_unregister(Main *UNUSED(bmain), StructRNA *type)
static bool rna_NodeSocket_unregister(Main *UNUSED(bmain), StructRNA *type)
{
bNodeSocketType *st = RNA_struct_blender_type_get(type);
if (!st) {
return;
return false;
}
RNA_struct_free_extension(type, &st->ext_socket);
@ -2739,6 +2763,7 @@ static void rna_NodeSocket_unregister(Main *UNUSED(bmain), StructRNA *type)
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
return true;
}
static StructRNA *rna_NodeSocket_register(Main *UNUSED(bmain),
@ -3018,11 +3043,11 @@ static void rna_NodeSocketInterface_from_socket(bNodeTree *ntree,
RNA_parameter_list_free(&list);
}
static void rna_NodeSocketInterface_unregister(Main *UNUSED(bmain), StructRNA *type)
static bool rna_NodeSocketInterface_unregister(Main *UNUSED(bmain), StructRNA *type)
{
bNodeSocketType *st = RNA_struct_blender_type_get(type);
if (!st) {
return;
return false;
}
RNA_struct_free_extension(type, &st->ext_interface);
@ -3031,6 +3056,7 @@ static void rna_NodeSocketInterface_unregister(Main *UNUSED(bmain), StructRNA *t
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
return true;
}
static StructRNA *rna_NodeSocketInterface_register(Main *UNUSED(bmain),

View File

@ -307,12 +307,12 @@ static void engine_update_render_passes(RenderEngine *engine,
/* RenderEngine registration */
static void rna_RenderEngine_unregister(Main *bmain, StructRNA *type)
static bool rna_RenderEngine_unregister(Main *bmain, StructRNA *type)
{
RenderEngineType *et = RNA_struct_blender_type_get(type);
if (!et) {
return;
return false;
}
/* Stop all renders in case we were using this one. */
@ -322,6 +322,7 @@ static void rna_RenderEngine_unregister(Main *bmain, StructRNA *type)
RNA_struct_free_extension(type, &et->rna_ext);
RNA_struct_free(&BLENDER_RNA, type);
BLI_freelinkN(&R_engines, et);
return true;
}
static StructRNA *rna_RenderEngine_register(Main *bmain,
@ -332,6 +333,7 @@ static StructRNA *rna_RenderEngine_register(Main *bmain,
StructCallbackFunc call,
StructFreeFunc free)
{
const char *error_prefix = "Registering render engine class:";
RenderEngineType *et, dummyet = {NULL};
RenderEngine dummyengine = {NULL};
PointerRNA dummyptr;
@ -350,19 +352,26 @@ static StructRNA *rna_RenderEngine_register(Main *bmain,
if (strlen(identifier) >= sizeof(dummyet.idname)) {
BKE_reportf(reports,
RPT_ERROR,
"Registering render engine class: '%s' is too long, maximum length is %d",
"%s '%s' is too long, maximum length is %d",
error_prefix,
identifier,
(int)sizeof(dummyet.idname));
return NULL;
}
/* check if we have registered this engine type before, and remove it */
for (et = R_engines.first; et; et = et->next) {
if (STREQ(et->idname, dummyet.idname)) {
if (et->rna_ext.srna) {
rna_RenderEngine_unregister(bmain, et->rna_ext.srna);
}
break;
/* Check if we have registered this engine type before, and remove it. */
et = BLI_findstring(&R_engines, dummyet.idname, offsetof(RenderEngineType, idname));
if (et) {
StructRNA *srna = et->rna_ext.srna;
if (!(srna && rna_RenderEngine_unregister(bmain, srna))) {
BKE_reportf(reports,
RPT_ERROR,
"%s '%s', bl_idname '%s' %s",
error_prefix,
identifier,
dummyet.idname,
srna ? "is built-in" : "could not be unregistered");
return NULL;
}
}

View File

@ -178,16 +178,16 @@ static void panel_type_clear_recursive(Panel *panel, const PanelType *type)
}
}
static void rna_Panel_unregister(Main *bmain, StructRNA *type)
static bool rna_Panel_unregister(Main *bmain, StructRNA *type)
{
ARegionType *art;
PanelType *pt = RNA_struct_blender_type_get(type);
if (!pt) {
return;
return false;
}
if (!(art = region_type_find(NULL, pt->space_type, pt->region_type))) {
return;
return false;
}
RNA_struct_free_extension(type, &pt->rna_ext);
@ -232,6 +232,7 @@ static void rna_Panel_unregister(Main *bmain, StructRNA *type)
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
return true;
}
static StructRNA *rna_Panel_register(Main *bmain,
@ -242,6 +243,7 @@ static StructRNA *rna_Panel_register(Main *bmain,
StructCallbackFunc call,
StructFreeFunc free)
{
const char *error_prefix = "Registering panel class:";
ARegionType *art;
PanelType *pt, *parent = NULL, dummypt = {NULL};
Panel dummypanel = {NULL};
@ -268,7 +270,8 @@ static StructRNA *rna_Panel_register(Main *bmain,
if (strlen(identifier) >= sizeof(dummypt.idname)) {
BKE_reportf(reports,
RPT_ERROR,
"Registering panel class: '%s' is too long, maximum length is %d",
"%s '%s' is too long, maximum length is %d",
error_prefix,
identifier,
(int)sizeof(dummypt.idname));
return NULL;
@ -279,8 +282,7 @@ static StructRNA *rna_Panel_register(Main *bmain,
/* Use a fallback, otherwise an empty value will draw the panel in every category. */
strcpy(dummypt.category, PNL_CATEGORY_FALLBACK);
# ifndef NDEBUG
printf("Registering panel class: '%s' misses category, please update the script\n",
dummypt.idname);
printf("%s '%s' misses category, please update the script\n", error_prefix, dummypt.idname);
# endif
}
}
@ -289,7 +291,8 @@ static StructRNA *rna_Panel_register(Main *bmain,
if ((1 << dummypt.space_type) & WM_TOOLSYSTEM_SPACE_MASK) {
BKE_reportf(reports,
RPT_ERROR,
"Registering panel class: '%s' has category '%s' ",
"%s '%s' has category '%s' ",
error_prefix,
dummypt.idname,
dummypt.category);
return NULL;
@ -305,8 +308,16 @@ static StructRNA *rna_Panel_register(Main *bmain,
for (pt = art->paneltypes.first; pt; pt = pt->next) {
if (STREQ(pt->idname, dummypt.idname)) {
PanelType *pt_next = pt->next;
if (pt->rna_ext.srna) {
rna_Panel_unregister(bmain, pt->rna_ext.srna);
StructRNA *srna = pt->rna_ext.srna;
if (srna) {
if (!rna_Panel_unregister(bmain, srna)) {
BKE_reportf(reports,
RPT_ERROR,
"%s '%s', bl_idname '%s' could not be unregistered",
error_prefix,
identifier,
dummypt.idname);
}
}
else {
BLI_freelinkN(&art->paneltypes, pt);
@ -339,7 +350,8 @@ static StructRNA *rna_Panel_register(Main *bmain,
if (dummypt.parent_id[0] && !parent) {
BKE_reportf(reports,
RPT_ERROR,
"Registering panel class: parent '%s' for '%s' not found",
"%s parent '%s' for '%s' not found",
error_prefix,
dummypt.parent_id,
dummypt.idname);
return NULL;
@ -647,12 +659,12 @@ static void uilist_filter_items(uiList *ui_list,
RNA_parameter_list_free(&list);
}
static void rna_UIList_unregister(Main *bmain, StructRNA *type)
static bool rna_UIList_unregister(Main *bmain, StructRNA *type)
{
uiListType *ult = RNA_struct_blender_type_get(type);
if (!ult) {
return;
return false;
}
RNA_struct_free_extension(type, &ult->rna_ext);
@ -662,6 +674,7 @@ static void rna_UIList_unregister(Main *bmain, StructRNA *type)
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
return true;
}
static StructRNA *rna_UIList_register(Main *bmain,
@ -672,6 +685,7 @@ static StructRNA *rna_UIList_register(Main *bmain,
StructCallbackFunc call,
StructFreeFunc free)
{
const char *error_prefix = "Registering uilist class:";
uiListType *ult, dummyult = {NULL};
uiList dummyuilist = {NULL};
PointerRNA dummyul_ptr;
@ -690,7 +704,8 @@ static StructRNA *rna_UIList_register(Main *bmain,
if (strlen(identifier) >= sizeof(dummyult.idname)) {
BKE_reportf(reports,
RPT_ERROR,
"Registering uilist class: '%s' is too long, maximum length is %d",
"%s '%s' is too long, maximum length is %d",
error_prefix,
identifier,
(int)sizeof(dummyult.idname));
return NULL;
@ -698,8 +713,18 @@ static StructRNA *rna_UIList_register(Main *bmain,
/* Check if we have registered this UI-list type before, and remove it. */
ult = WM_uilisttype_find(dummyult.idname, true);
if (ult && ult->rna_ext.srna) {
rna_UIList_unregister(bmain, ult->rna_ext.srna);
if (ult) {
StructRNA *srna = ult->rna_ext.srna;
if (!(srna && rna_UIList_unregister(bmain, srna))) {
BKE_reportf(reports,
RPT_ERROR,
"%s '%s', bl_idname '%s' %s",
error_prefix,
identifier,
dummyult.idname,
srna ? "is built-in" : "could not be unregistered");
return NULL;
}
}
if (!RNA_struct_available_or_report(reports, dummyult.idname)) {
return NULL;
@ -757,16 +782,16 @@ static void header_draw(const bContext *C, Header *hdr)
RNA_parameter_list_free(&list);
}
static void rna_Header_unregister(Main *UNUSED(bmain), StructRNA *type)
static bool rna_Header_unregister(Main *UNUSED(bmain), StructRNA *type)
{
ARegionType *art;
HeaderType *ht = RNA_struct_blender_type_get(type);
if (!ht) {
return;
return false;
}
if (!(art = region_type_find(NULL, ht->space_type, ht->region_type))) {
return;
return false;
}
RNA_struct_free_extension(type, &ht->rna_ext);
@ -776,6 +801,7 @@ static void rna_Header_unregister(Main *UNUSED(bmain), StructRNA *type)
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
return true;
}
static StructRNA *rna_Header_register(Main *bmain,
@ -786,6 +812,7 @@ static StructRNA *rna_Header_register(Main *bmain,
StructCallbackFunc call,
StructFreeFunc free)
{
const char *error_prefix = "Registering header class:";
ARegionType *art;
HeaderType *ht, dummyht = {NULL};
Header dummyheader = {NULL};
@ -805,7 +832,8 @@ static StructRNA *rna_Header_register(Main *bmain,
if (strlen(identifier) >= sizeof(dummyht.idname)) {
BKE_reportf(reports,
RPT_ERROR,
"Registering header class: '%s' is too long, maximum length is %d",
"%s '%s' is too long, maximum length is %d",
error_prefix,
identifier,
(int)sizeof(dummyht.idname));
return NULL;
@ -816,14 +844,21 @@ static StructRNA *rna_Header_register(Main *bmain,
}
/* check if we have registered this header type before, and remove it */
for (ht = art->headertypes.first; ht; ht = ht->next) {
if (STREQ(ht->idname, dummyht.idname)) {
if (ht->rna_ext.srna) {
rna_Header_unregister(bmain, ht->rna_ext.srna);
}
break;
ht = BLI_findstring(&art->headertypes, dummyht.idname, offsetof(HeaderType, idname));
if (ht) {
StructRNA *srna = ht->rna_ext.srna;
if (!(srna && rna_Header_unregister(bmain, srna))) {
BKE_reportf(reports,
RPT_ERROR,
"%s '%s', bl_idname '%s' %s",
error_prefix,
identifier,
dummyht.idname,
srna ? "is built-in" : "could not be unregistered");
return NULL;
}
}
if (!RNA_struct_available_or_report(reports, dummyht.idname)) {
return NULL;
}
@ -902,12 +937,12 @@ static void menu_draw(const bContext *C, Menu *menu)
RNA_parameter_list_free(&list);
}
static void rna_Menu_unregister(Main *UNUSED(bmain), StructRNA *type)
static bool rna_Menu_unregister(Main *UNUSED(bmain), StructRNA *type)
{
MenuType *mt = RNA_struct_blender_type_get(type);
if (!mt) {
return;
return false;
}
RNA_struct_free_extension(type, &mt->rna_ext);
@ -917,6 +952,7 @@ static void rna_Menu_unregister(Main *UNUSED(bmain), StructRNA *type)
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
return true;
}
static StructRNA *rna_Menu_register(Main *bmain,
@ -927,6 +963,7 @@ static StructRNA *rna_Menu_register(Main *bmain,
StructCallbackFunc call,
StructFreeFunc free)
{
const char *error_prefix = "Registering menu class:";
MenuType *mt, dummymt = {NULL};
Menu dummymenu = {NULL};
PointerRNA dummymtr;
@ -952,7 +989,8 @@ static StructRNA *rna_Menu_register(Main *bmain,
if (strlen(identifier) >= sizeof(dummymt.idname)) {
BKE_reportf(reports,
RPT_ERROR,
"Registering menu class: '%s' is too long, maximum length is %d",
"%s '%s' is too long, maximum length is %d",
error_prefix,
identifier,
(int)sizeof(dummymt.idname));
return NULL;
@ -960,8 +998,18 @@ static StructRNA *rna_Menu_register(Main *bmain,
/* check if we have registered this menu type before, and remove it */
mt = WM_menutype_find(dummymt.idname, true);
if (mt && mt->rna_ext.srna) {
rna_Menu_unregister(bmain, mt->rna_ext.srna);
if (mt) {
StructRNA *srna = mt->rna_ext.srna;
if (!(srna && rna_Menu_unregister(bmain, srna))) {
BKE_reportf(reports,
RPT_ERROR,
"%s '%s', bl_idname '%s' %s",
error_prefix,
identifier,
dummymt.idname,
srna ? "is built-in" : "could not be unregistered");
return NULL;
}
}
if (!RNA_struct_available_or_report(reports, dummymt.idname)) {
return NULL;

View File

@ -792,12 +792,12 @@ static PointerRNA rna_Addon_preferences_get(PointerRNA *ptr)
}
}
static void rna_AddonPref_unregister(Main *UNUSED(bmain), StructRNA *type)
static bool rna_AddonPref_unregister(Main *UNUSED(bmain), StructRNA *type)
{
bAddonPrefType *apt = RNA_struct_blender_type_get(type);
if (!apt) {
return;
return false;
}
RNA_struct_free_extension(type, &apt->rna_ext);
@ -807,6 +807,7 @@ static void rna_AddonPref_unregister(Main *UNUSED(bmain), StructRNA *type)
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
return true;
}
static StructRNA *rna_AddonPref_register(Main *bmain,
@ -817,6 +818,7 @@ static StructRNA *rna_AddonPref_register(Main *bmain,
StructCallbackFunc call,
StructFreeFunc free)
{
const char *error_prefix = "Registering add-on preferences class:";
bAddonPrefType *apt, dummy_apt = {{'\0'}};
bAddon dummy_addon = {NULL};
PointerRNA dummy_ptr;
@ -834,7 +836,8 @@ static StructRNA *rna_AddonPref_register(Main *bmain,
if (strlen(identifier) >= sizeof(dummy_apt.idname)) {
BKE_reportf(reports,
RPT_ERROR,
"Registering add-on preferences class: '%s' is too long, maximum length is %d",
"%s '%s' is too long, maximum length is %d",
error_prefix,
identifier,
(int)sizeof(dummy_apt.idname));
return NULL;
@ -842,8 +845,19 @@ static StructRNA *rna_AddonPref_register(Main *bmain,
/* Check if we have registered this add-on preference type before, and remove it. */
apt = BKE_addon_pref_type_find(dummy_addon.module, true);
if (apt && apt->rna_ext.srna) {
rna_AddonPref_unregister(bmain, apt->rna_ext.srna);
if (apt) {
StructRNA *srna = apt->rna_ext.srna;
if (!(srna && rna_AddonPref_unregister(bmain, srna))) {
BKE_reportf(reports,
RPT_ERROR,
"%s '%s', bl_idname '%s' %s",
error_prefix,
identifier,
dummy_apt.idname,
srna ? "is built-in" : "could not be unregistered");
return NULL;
}
}
/* Create a new add-on preference type. */

View File

@ -1111,12 +1111,12 @@ static IDProperty **rna_wmKeyConfigPref_idprops(PointerRNA *ptr)
return (IDProperty **)&ptr->data;
}
static void rna_wmKeyConfigPref_unregister(Main *UNUSED(bmain), StructRNA *type)
static bool rna_wmKeyConfigPref_unregister(Main *UNUSED(bmain), StructRNA *type)
{
wmKeyConfigPrefType_Runtime *kpt_rt = RNA_struct_blender_type_get(type);
if (!kpt_rt) {
return;
return false;
}
RNA_struct_free_extension(type, &kpt_rt->rna_ext);
@ -1127,6 +1127,7 @@ static void rna_wmKeyConfigPref_unregister(Main *UNUSED(bmain), StructRNA *type)
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
return true;
}
static StructRNA *rna_wmKeyConfigPref_register(Main *bmain,
@ -1137,6 +1138,7 @@ static StructRNA *rna_wmKeyConfigPref_register(Main *bmain,
StructCallbackFunc call,
StructFreeFunc free)
{
const char *error_prefix = "Registering key-config preferences class:";
wmKeyConfigPrefType_Runtime *kpt_rt, dummy_kpt_rt = {{'\0'}};
wmKeyConfigPref dummy_kpt = {NULL};
PointerRNA dummy_ptr;
@ -1154,7 +1156,8 @@ static StructRNA *rna_wmKeyConfigPref_register(Main *bmain,
if (strlen(identifier) >= sizeof(dummy_kpt_rt.idname)) {
BKE_reportf(reports,
RPT_ERROR,
"Registering key-config preferences class: '%s' is too long, maximum length is %d",
"%s '%s' is too long, maximum length is %d",
error_prefix,
identifier,
(int)sizeof(dummy_kpt_rt.idname));
return NULL;
@ -1162,8 +1165,18 @@ static StructRNA *rna_wmKeyConfigPref_register(Main *bmain,
/* check if we have registered this keyconf-prefs type before, and remove it */
kpt_rt = BKE_keyconfig_pref_type_find(dummy_kpt.idname, true);
if (kpt_rt && kpt_rt->rna_ext.srna) {
rna_wmKeyConfigPref_unregister(bmain, kpt_rt->rna_ext.srna);
if (kpt_rt) {
StructRNA *srna = kpt_rt->rna_ext.srna;
if (!(srna && rna_wmKeyConfigPref_unregister(bmain, srna))) {
BKE_reportf(reports,
RPT_ERROR,
"%s '%s', bl_idname '%s' %s",
error_prefix,
identifier,
dummy_kpt.idname,
srna ? "is built-in" : "could not be unregistered");
return NULL;
}
}
/* create a new keyconf-prefs type */
@ -1456,7 +1469,7 @@ static char *rna_operator_description_cb(bContext *C, wmOperatorType *ot, Pointe
return result;
}
static void rna_Operator_unregister(struct Main *bmain, StructRNA *type);
static bool rna_Operator_unregister(struct Main *bmain, StructRNA *type);
/* bpy_operator_wrap.c */
@ -1471,6 +1484,7 @@ static StructRNA *rna_Operator_register(Main *bmain,
StructCallbackFunc call,
StructFreeFunc free)
{
const char *error_prefix = "Registering operator class:";
wmOperatorType dummyot = {NULL};
wmOperator dummyop = {NULL};
PointerRNA dummyotr;
@ -1506,8 +1520,18 @@ static StructRNA *rna_Operator_register(Main *bmain,
/* check if we have registered this operator type before, and remove it */
{
wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true);
if (ot && ot->rna_ext.srna) {
rna_Operator_unregister(bmain, ot->rna_ext.srna);
if (ot) {
StructRNA *srna = ot->rna_ext.srna;
if (!(srna && rna_Operator_unregister(bmain, srna))) {
BKE_reportf(reports,
RPT_ERROR,
"%s '%s', bl_idname '%s' %s",
error_prefix,
identifier,
dummyot.idname,
srna ? "is built-in" : "could not be unregistered");
return NULL;
}
}
}
@ -1580,14 +1604,14 @@ static StructRNA *rna_Operator_register(Main *bmain,
return dummyot.rna_ext.srna;
}
static void rna_Operator_unregister(struct Main *bmain, StructRNA *type)
static bool rna_Operator_unregister(struct Main *bmain, StructRNA *type)
{
const char *idname;
wmOperatorType *ot = RNA_struct_blender_type_get(type);
wmWindowManager *wm;
if (!ot) {
return;
return false;
}
/* update while blender is running */
@ -1609,6 +1633,7 @@ static void rna_Operator_unregister(struct Main *bmain, StructRNA *type)
RNA_struct_free(&BLENDER_RNA, type);
MEM_freeN((void *)idname);
return true;
}
static void **rna_Operator_instance(PointerRNA *ptr)
@ -1625,6 +1650,7 @@ static StructRNA *rna_MacroOperator_register(Main *bmain,
StructCallbackFunc call,
StructFreeFunc free)
{
const char *error_prefix = "Registering operator macro class:";
wmOperatorType dummyot = {NULL};
wmOperator dummyop = {NULL};
PointerRNA dummyotr;
@ -1664,8 +1690,18 @@ static StructRNA *rna_MacroOperator_register(Main *bmain,
/* check if we have registered this operator type before, and remove it */
{
wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true);
if (ot && ot->rna_ext.srna) {
rna_Operator_unregister(bmain, ot->rna_ext.srna);
if (ot) {
StructRNA *srna = ot->rna_ext.srna;
if (!(srna && rna_Operator_unregister(bmain, srna))) {
BKE_reportf(reports,
RPT_ERROR,
"%s '%s', bl_idname '%s' %s",
error_prefix,
identifier,
dummyot.idname,
srna ? "is built-in" : "could not be unregistered");
return NULL;
}
}
}

View File

@ -415,7 +415,7 @@ static PointerRNA rna_Gizmo_group_get(PointerRNA *ptr)
# ifdef WITH_PYTHON
static void rna_Gizmo_unregister(struct Main *bmain, StructRNA *type);
static bool rna_Gizmo_unregister(struct Main *bmain, StructRNA *type);
void BPY_RNA_gizmo_wrapper(wmGizmoType *gzgt, void *userdata);
static StructRNA *rna_Gizmo_register(Main *bmain,
@ -426,6 +426,7 @@ static StructRNA *rna_Gizmo_register(Main *bmain,
StructCallbackFunc call,
StructFreeFunc free)
{
const char *error_prefix = "Registering gizmo class:";
struct {
char idname[MAX_NAME];
} temp_buffers;
@ -453,7 +454,8 @@ static StructRNA *rna_Gizmo_register(Main *bmain,
if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
BKE_reportf(reports,
RPT_ERROR,
"Registering gizmo class: '%s' is too long, maximum length is %d",
"%s '%s' is too long, maximum length is %d",
error_prefix,
identifier,
(int)sizeof(temp_buffers.idname));
return NULL;
@ -462,8 +464,18 @@ static StructRNA *rna_Gizmo_register(Main *bmain,
/* check if we have registered this gizmo type before, and remove it */
{
const wmGizmoType *gzt = WM_gizmotype_find(dummygt.idname, true);
if (gzt && gzt->rna_ext.srna) {
rna_Gizmo_unregister(bmain, gzt->rna_ext.srna);
if (gzt) {
StructRNA *srna = gzt->rna_ext.srna;
if (!(srna && rna_Gizmo_unregister(bmain, srna))) {
BKE_reportf(reports,
RPT_ERROR,
"%s '%s', bl_idname '%s' %s",
error_prefix,
identifier,
dummygt.idname,
srna ? "is built-in" : "could not be unregistered");
return NULL;
}
}
}
if (!RNA_struct_available_or_report(reports, dummygt.idname)) {
@ -507,12 +519,12 @@ static StructRNA *rna_Gizmo_register(Main *bmain,
return dummygt.rna_ext.srna;
}
static void rna_Gizmo_unregister(struct Main *bmain, StructRNA *type)
static bool rna_Gizmo_unregister(struct Main *bmain, StructRNA *type)
{
wmGizmoType *gzt = RNA_struct_blender_type_get(type);
if (!gzt) {
return;
return false;
}
WM_gizmotype_remove_ptr(NULL, bmain, gzt);
@ -525,6 +537,7 @@ static void rna_Gizmo_unregister(struct Main *bmain, StructRNA *type)
WM_gizmotype_free_ptr(gzt);
WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
return true;
}
static void **rna_Gizmo_instance(PointerRNA *ptr)
@ -784,7 +797,7 @@ static void rna_gizmogroup_invoke_prepare_cb(const bContext *C,
}
void BPY_RNA_gizmogroup_wrapper(wmGizmoGroupType *gzgt, void *userdata);
static void rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type);
static bool rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type);
static StructRNA *rna_GizmoGroup_register(Main *bmain,
ReportList *reports,
@ -794,6 +807,7 @@ static StructRNA *rna_GizmoGroup_register(Main *bmain,
StructCallbackFunc call,
StructFreeFunc free)
{
const char *error_prefix = "Registering gizmogroup class:";
struct {
char name[MAX_NAME];
char idname[MAX_NAME];
@ -824,7 +838,8 @@ static StructRNA *rna_GizmoGroup_register(Main *bmain,
if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
BKE_reportf(reports,
RPT_ERROR,
"Registering gizmogroup class: '%s' is too long, maximum length is %d",
"%s '%s' is too long, maximum length is %d",
error_prefix,
identifier,
(int)sizeof(temp_buffers.idname));
return NULL;
@ -838,15 +853,25 @@ static StructRNA *rna_GizmoGroup_register(Main *bmain,
wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(&wmap_params);
if (gzmap_type == NULL) {
BKE_report(reports, RPT_ERROR, "Area type does not support gizmos");
BKE_reportf(reports, RPT_ERROR, "%s area type does not support gizmos", error_prefix);
return NULL;
}
/* check if we have registered this gizmogroup type before, and remove it */
{
wmGizmoGroupType *gzgt = WM_gizmogrouptype_find(dummywgt.idname, true);
if (gzgt && gzgt->rna_ext.srna) {
rna_GizmoGroup_unregister(bmain, gzgt->rna_ext.srna);
if (gzgt) {
StructRNA *srna = gzgt->rna_ext.srna;
if (!(srna && rna_GizmoGroup_unregister(bmain, srna))) {
BKE_reportf(reports,
RPT_ERROR,
"%s '%s', bl_idname '%s' %s",
error_prefix,
identifier,
dummywgt.idname,
srna ? "is built-in" : "could not be unregistered");
return NULL;
}
}
}
if (!RNA_struct_available_or_report(reports, dummywgt.idname)) {
@ -906,12 +931,12 @@ static StructRNA *rna_GizmoGroup_register(Main *bmain,
return dummywgt.rna_ext.srna;
}
static void rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type)
static bool rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type)
{
wmGizmoGroupType *gzgt = RNA_struct_blender_type_get(type);
if (!gzgt) {
return;
return false;
}
WM_gizmo_group_type_remove_ptr(bmain, gzgt);
@ -924,6 +949,7 @@ static void rna_GizmoGroup_unregister(struct Main *bmain, StructRNA *type)
WM_gizmo_group_type_free_ptr(gzgt);
WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
return true;
}
static void **rna_GizmoGroup_instance(PointerRNA *ptr)