diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-01-23 11:01:52 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-01-23 12:05:56 +0400 |
commit | b64f897606ecd1cc14ccbef9f54a054452e39a63 (patch) | |
tree | 09d6c5b512629646115d20956a4de41d0a9d3138 /source/blender | |
parent | 12348318d1533c6ff62b9f4b1c64268fb13cefad (diff) |
WM: add WM_operatortype_remove_ptr to remove a known operator
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 21 |
3 files changed, 17 insertions, 9 deletions
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index f4f2f834398..b82dae1bf23 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -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 */ diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index b635544add0..1690a1a8641 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -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); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 255d6f19789..3638403660d 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -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 */ |