Merge branch 'master' into blender2.8

This commit is contained in:
2018-02-12 17:39:58 +11:00
6 changed files with 87 additions and 25 deletions

View File

@@ -26,8 +26,11 @@
* \ingroup bke
*/
#include "RNA_types.h"
struct ListBase;
struct bAddon;
#ifdef __RNA_TYPES_H__
typedef struct bAddonPrefType {
/* type info */
char idname[64]; // best keep the same size as BKE_ST_MAXNAME
@@ -36,6 +39,10 @@ typedef struct bAddonPrefType {
ExtensionRNA ext;
} bAddonPrefType;
#else
typedef struct bAddonPrefType bAddonPrefType;
#endif
bAddonPrefType *BKE_addon_pref_type_find(const char *idname, bool quiet);
void BKE_addon_pref_type_add(bAddonPrefType *apt);
void BKE_addon_pref_type_remove(const bAddonPrefType *apt);
@@ -43,4 +50,8 @@ void BKE_addon_pref_type_remove(const bAddonPrefType *apt);
void BKE_addon_pref_type_init(void);
void BKE_addon_pref_type_free(void);
struct bAddon *BKE_addon_new(void);
struct bAddon *BKE_addon_ensure(struct ListBase *addons, const char *module);
void BKE_addon_free(struct bAddon *addon);
#endif /* __BKE_ADDON_H__ */

View File

@@ -27,13 +27,59 @@
#include <stddef.h>
#include <stdlib.h>
#include "RNA_types.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
#include "BLI_string.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BKE_addon.h" /* own include */
#include "BKE_idprop.h"
#include "DNA_listBase.h"
#include "DNA_userdef_types.h"
#include "MEM_guardedalloc.h"
/* -------------------------------------------------------------------- */
/** \name Add-on New/Free
* \{ */
bAddon *BKE_addon_new(void)
{
bAddon *addon = MEM_callocN(sizeof(bAddon), "bAddon");
return addon;
}
bAddon *BKE_addon_ensure(ListBase *addon_list, const char *module)
{
bAddon *addon = BLI_findstring(addon_list, module, offsetof(bAddon, module));
if (addon == NULL) {
addon = BKE_addon_new();
BLI_strncpy(addon->module, module, sizeof(addon->module));
BLI_addtail(addon_list, addon);
}
return addon;
}
void BKE_addon_free(bAddon *addon)
{
if (addon->prop) {
IDP_FreeProperty(addon->prop);
MEM_freeN(addon->prop);
}
MEM_freeN(addon);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Add-on Preference API
* \{ */
static GHash *global_addonpreftype_hash = NULL;
@@ -81,3 +127,5 @@ void BKE_addon_pref_type_free(void)
BLI_ghash_free(global_addonpreftype_hash, NULL, MEM_freeN);
global_addonpreftype_hash = NULL;
}
/** \} */

View File

@@ -45,6 +45,7 @@
#include "IMB_imbuf.h"
#include "IMB_moviecache.h"
#include "BKE_addon.h"
#include "BKE_blender.h" /* own include */
#include "BKE_blender_version.h" /* own include */
#include "BKE_blendfile.h"
@@ -202,11 +203,7 @@ static void userdef_free_addons(UserDef *userdef)
{
for (bAddon *addon = userdef->addons.first, *addon_next; addon; addon = addon_next) {
addon_next = addon->next;
if (addon->prop) {
IDP_FreeProperty(addon->prop);
MEM_freeN(addon->prop);
}
MEM_freeN(addon);
BKE_addon_free(addon);
}
BLI_listbase_clear(&userdef->addons);
}

View File

@@ -83,6 +83,10 @@ if(WITH_HEADLESS)
add_definitions(-DWITH_HEADLESS)
endif()
if(WITH_CYCLES)
add_definitions(-DWITH_CYCLES)
endif()
if(WITH_PYTHON)
add_definitions(-DWITH_PYTHON)
endif()

View File

@@ -45,6 +45,7 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BKE_addon.h"
#include "BKE_appdir.h"
#include "BKE_colorband.h"
#include "BKE_DerivedMesh.h"
@@ -2307,13 +2308,19 @@ void init_userdef_do_versions(void)
if (btheme->tipo.handle_sel_auto_clamped[3] == 0)
rgba_char_args_set(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
}
#ifdef WITH_CYCLES
/* enable (Cycles) addon by default */
if (!BLI_findstring(&U.addons, "cycles", offsetof(bAddon, module))) {
bAddon *baddon = MEM_callocN(sizeof(bAddon), "bAddon");
BLI_strncpy(baddon->module, "cycles", sizeof(baddon->module));
BLI_addtail(&U.addons, baddon);
BKE_addon_ensure(&U.addons, "cycles");
#else
{
bAddon *addon = BLI_findstring(&U.addons, "cycles", offsetof(bAddon, module));
if (addon) {
BKE_addon_free(addon);
BLI_remlink(&U.addons, addon);
}
}
#endif
}
if (!USER_VERSION_ATLEAST(260, 5)) {

View File

@@ -399,27 +399,22 @@ static void rna_userdef_autosave_update(Main *bmain, Scene *scene, PointerRNA *p
static bAddon *rna_userdef_addon_new(void)
{
ListBase *addons_list = &U.addons;
bAddon *bext = MEM_callocN(sizeof(bAddon), "bAddon");
BLI_addtail(addons_list, bext);
return bext;
bAddon *addon = BKE_addon_new();
BLI_addtail(addons_list, addon);
return addon;
}
static void rna_userdef_addon_remove(ReportList *reports, PointerRNA *bext_ptr)
static void rna_userdef_addon_remove(ReportList *reports, PointerRNA *addon_ptr)
{
ListBase *addons_list = &U.addons;
bAddon *bext = bext_ptr->data;
if (BLI_findindex(addons_list, bext) == -1) {
bAddon *addon = addon_ptr->data;
if (BLI_findindex(addons_list, addon) == -1) {
BKE_report(reports, RPT_ERROR, "Add-on is no longer valid");
return;
}
if (bext->prop) {
IDP_FreeProperty(bext->prop);
MEM_freeN(bext->prop);
}
BLI_freelinkN(addons_list, bext);
RNA_POINTER_INVALIDATE(bext_ptr);
BLI_remlink(addons_list, addon);
BKE_addon_free(addon);
RNA_POINTER_INVALIDATE(addon_ptr);
}
static bPathCompare *rna_userdef_pathcompare_new(void)