WM: add WM_operatortype_remove_ptr to remove a known operator
authorCampbell Barton <ideasman42@gmail.com>
Thu, 23 Jan 2014 07:01:52 +0000 (18:01 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 23 Jan 2014 08:05:56 +0000 (19:05 +1100)
source/blender/makesrna/intern/rna_wm.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_operators.c
source/blenderplayer/bad_level_call_stubs/stubs.c

index f4f2f8343989c411b97304830b7243a88584286c..b82dae1bf23ff9d5d43159d2d5a5cc278215187d 100644 (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 */
index b635544add0aa7b590ffb9b083dd5b7224f73f31..1690a1a8641dfc380c610a9ef1b92c73d82a2e71 100644 (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);
index 255d6f19789b011756c47ffa2235e5abd6b6aa40..3638403660d949b72c2c008fc803572b7979fe26 100644 (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 */
index e0d27eb9b2875ae5d7e033a212519f695377e38a..18422554dced2ca9c69a054014d4b7aff3f6999f 100644 (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;}