From d56b90705e81768ca1a586b622ef4bbe3b216d5c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Jul 2018 07:55:29 +0200 Subject: BKE_addons: utility to remove by name --- source/blender/blenkernel/BKE_addon.h | 1 + source/blender/blenkernel/intern/addon.c | 11 +++++++++++ source/blender/editors/interface/resources.c | 6 +----- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_addon.h b/source/blender/blenkernel/BKE_addon.h index 3af6d3b61bf..a463525d644 100644 --- a/source/blender/blenkernel/BKE_addon.h +++ b/source/blender/blenkernel/BKE_addon.h @@ -53,6 +53,7 @@ void BKE_addon_pref_type_free(void); struct bAddon *BKE_addon_new(void); struct bAddon *BKE_addon_find(struct ListBase *addon_list, const char *module); struct bAddon *BKE_addon_ensure(struct ListBase *addon_list, const char *module); +bool BKE_addon_remove_safe(struct ListBase *addon_list, const char *module); void BKE_addon_free(struct bAddon *addon); #endif /* __BKE_ADDON_H__ */ diff --git a/source/blender/blenkernel/intern/addon.c b/source/blender/blenkernel/intern/addon.c index a9bb193a7a1..854bf62c061 100644 --- a/source/blender/blenkernel/intern/addon.c +++ b/source/blender/blenkernel/intern/addon.c @@ -69,6 +69,17 @@ bAddon *BKE_addon_ensure(ListBase *addon_list, const char *module) return addon; } +bool BKE_addon_remove_safe(ListBase *addon_list, const char *module) +{ + bAddon *addon = BLI_findstring(addon_list, module, offsetof(bAddon, module)); + if (addon) { + BLI_remlink(addon_list, addon); + BKE_addon_free(addon); + return true; + } + return false; +} + void BKE_addon_free(bAddon *addon) { if (addon->prop) { diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index b9da0923e07..77c36bf47f3 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -2788,11 +2788,7 @@ void init_userdef_do_versions(Main *bmain) /* Not versioning, just avoid errors. */ #ifndef WITH_CYCLES - bAddon *addon = BLI_findstring(&U.addons, "cycles", offsetof(bAddon, module)); - if (addon) { - BLI_remlink(&U.addons, addon); - BKE_addon_free(addon); - } + BKE_addon_remove_safe(&U.addons, "cycles"); #endif /* funny name, but it is GE stuff, moves userdef stuff to engine */ -- cgit v1.2.3