diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_blender.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_blendfile.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender.c | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blendfile.c | 18 |
4 files changed, 20 insertions, 17 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 040df054ec5..62a15bae153 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -48,9 +48,10 @@ void BKE_blender_version_string( char *version_str, size_t maxncpy, short version, short subversion, bool v_prefix, bool include_subversion); -void BKE_blender_userdef_free(struct UserDef *userdef); +void BKE_blender_userdef_set_data(struct UserDef *userdef); +void BKE_blender_userdef_free_data(struct UserDef *userdef); void BKE_blender_userdef_refresh(void); - + /* set this callback when a UI is running */ void BKE_blender_callback_test_break_set(void (*func)(void)); int BKE_blender_test_break(void); diff --git a/source/blender/blenkernel/BKE_blendfile.h b/source/blender/blenkernel/BKE_blendfile.h index 6e6d1455b21..9625a93ed06 100644 --- a/source/blender/blenkernel/BKE_blendfile.h +++ b/source/blender/blenkernel/BKE_blendfile.h @@ -33,6 +33,7 @@ struct ID; struct Main; struct MemFile; struct ReportList; +struct UserDef; enum { BKE_BLENDFILE_READ_FAIL = 0, /* no load */ @@ -50,8 +51,8 @@ bool BKE_blendfile_read_from_memfile( struct bContext *C, struct MemFile *memfile, struct ReportList *reports, int skip_flag); -int BKE_blendfile_read_userdef(const char *filepath, struct ReportList *reports); -int BKE_blendfile_write_userdef(const char *filepath, struct ReportList *reports); +struct UserDef *BKE_blendfile_userdef_read(const char *filepath, struct ReportList *reports); +int BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports); /* partial blend file writing */ diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 0180e68faed..1febeebf9ea 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -150,11 +150,18 @@ static void keymap_item_free(wmKeyMapItem *kmi) MEM_freeN(kmi->ptr); } +void BKE_blender_userdef_set_data(UserDef *userdef) +{ + /* only here free userdef themes... */ + BKE_blender_userdef_free_data(&U); + U = *userdef; +} + /** * When loading a new userdef from file, * or when exiting Blender. */ -void BKE_blender_userdef_free(UserDef *userdef) +void BKE_blender_userdef_free_data(UserDef *userdef) { #define U _invalid_access_ /* ensure no accidental global access */ #ifdef U /* quiet warning */ diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 8b472249939..c549c138ef2 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -227,7 +227,7 @@ static void setup_app_data( if (bfd->user) { /* only here free userdef themes... */ - BKE_blender_userdef_free(&U); + BKE_blender_userdef_free_data(&U); U = *bfd->user; @@ -425,31 +425,25 @@ bool BKE_blendfile_read_from_memfile( } /* only read the userdef from a .blend */ -int BKE_blendfile_read_userdef(const char *filepath, ReportList *reports) +UserDef *BKE_blendfile_userdef_read(const char *filepath, ReportList *reports) { BlendFileData *bfd; - int retval = BKE_BLENDFILE_READ_FAIL; + UserDef *userdef = NULL; bfd = BLO_read_from_file(filepath, reports, BLO_READ_SKIP_NONE); if (bfd) { if (bfd->user) { - retval = BKE_BLENDFILE_READ_OK_USERPREFS; - - /* only here free userdef themes... */ - BKE_blender_userdef_free(&U); - - U = *bfd->user; - MEM_freeN(bfd->user); + userdef = bfd->user; } BKE_main_free(bfd->main); MEM_freeN(bfd); } - return retval; + return userdef; } /* only write the userdef in a .blend */ -int BKE_blendfile_write_userdef(const char *filepath, ReportList *reports) +int BKE_blendfile_userdef_write(const char *filepath, ReportList *reports) { Main *mainb = MEM_callocN(sizeof(Main), "empty main"); int retval = 0; |