WM: add WM_operatortype_remove_ptr to remove a known operator

This commit is contained in:
2014-01-23 18:01:52 +11:00
parent 12348318d1
commit b64f897606
4 changed files with 19 additions and 10 deletions

View File

@@ -887,7 +887,7 @@ static void rna_Operator_unregister(struct Main *bmain, StructRNA *type)
RNA_struct_free_extension(type, &ot->ext);
idname = ot->idname;
WM_operatortype_remove(ot->idname);
WM_operatortype_remove_ptr(ot);
MEM_freeN((void *)idname);
/* not to be confused with the RNA_struct_free that WM_operatortype_remove calls, they are 2 different srna's */

View File

@@ -218,7 +218,8 @@ struct GHashIterator *WM_operatortype_iter(void);
void WM_operatortype_append(void (*opfunc)(struct wmOperatorType *));
void WM_operatortype_append_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata);
void WM_operatortype_append_macro_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata);
int WM_operatortype_remove(const char *idname);
void WM_operatortype_remove_ptr(struct wmOperatorType *ot);
bool WM_operatortype_remove(const char *idname);
struct wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag);
struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname);

View File

@@ -461,14 +461,10 @@ static void wm_operatortype_free_macro(wmOperatorType *ot)
BLI_freelistN(&ot->macro);
}
int WM_operatortype_remove(const char *idname)
void WM_operatortype_remove_ptr(wmOperatorType *ot)
{
wmOperatorType *ot = WM_operatortype_find(idname, 0);
BLI_assert(ot == WM_operatortype_find(ot->idname, false));
if (ot == NULL)
return 0;
RNA_struct_free(&BLENDER_RNA, ot->srna);
if (ot->last_properties) {
@@ -482,7 +478,18 @@ int WM_operatortype_remove(const char *idname)
BLI_ghash_remove(global_ops_hash, (void *)ot->idname, NULL, NULL);
MEM_freeN(ot);
return 1;
}
bool WM_operatortype_remove(const char *idname)
{
wmOperatorType *ot = WM_operatortype_find(idname, 0);
if (ot == NULL)
return false;
WM_operatortype_remove_ptr(ot);
return true;
}
/* SOME_OT_op -> some.op */

View File

@@ -535,7 +535,8 @@ struct GHashIterator *WM_operatortype_iter() {STUB_ASSERT(0); return (struct GHa
struct wmOperatorType *WM_operatortype_exists(const char *idname) {STUB_ASSERT(0); return (struct wmOperatorType *) NULL;}
struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname) {STUB_ASSERT(0); return (struct wmOperatorTypeMacro *) NULL;}
int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, short context, short is_undo, struct PointerRNA *properties, struct ReportList *reports) {STUB_ASSERT(0); return 0;}
int WM_operatortype_remove(const char *idname) {STUB_ASSERT(0); return 0;}
void WM_operatortype_remove_ptr(struct wmOperatorType *ot) {STUB_ASSERT(0); }
bool WM_operatortype_remove(const char *idname) {STUB_ASSERT(0); return 0;}
int WM_operator_poll(struct bContext *C, struct wmOperatorType *ot) {STUB_ASSERT(0); return 0;}
int WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, int context) {STUB_ASSERT(0); return 0;}
int WM_operator_props_popup(struct bContext *C, struct wmOperator *op, struct wmEvent *event) {STUB_ASSERT(0); return 0;}