BKE_addons: utility to remove by name

This commit is contained in:
2018-07-06 07:55:29 +02:00
parent 52655f5161
commit d56b90705e
3 changed files with 13 additions and 5 deletions

View File

@@ -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__ */

View File

@@ -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) {

View File

@@ -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 */