diff options
Diffstat (limited to 'source')
-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 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 9 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 2 |
6 files changed, 27 insertions, 21 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; diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index f218fce1be3..c5b3d02cbb0 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -697,8 +697,11 @@ int wm_homefile_read( /* load preferences before startup.blend */ if (!from_memory && BLI_exists(filepath_userdef)) { - int done = BKE_blendfile_read_userdef(filepath_userdef, NULL); - if (done != BKE_BLENDFILE_READ_FAIL) { + UserDef *userdef = BKE_blendfile_userdef_read(filepath_userdef, NULL); + if (userdef != NULL) { + BKE_blender_userdef_set_data(userdef); + MEM_freeN(userdef); + read_userdef_from_memory = false; skip_flags |= BLO_READ_SKIP_USERDEF; printf("Read prefs: %s\n", filepath_userdef); @@ -1365,7 +1368,7 @@ static int wm_userpref_write_exec(bContext *C, wmOperator *op) BLI_make_file_string("/", filepath, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), BLENDER_USERPREF_FILE); printf("trying to save userpref at %s ", filepath); - if (BKE_blendfile_write_userdef(filepath, op->reports) == 0) { + if (BKE_blendfile_userdef_write(filepath, op->reports) == 0) { printf("fail\n"); return OPERATOR_CANCELLED; } diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 227e62d26d3..be74a0c7362 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -572,7 +572,7 @@ void WM_exit_ext(bContext *C, const bool do_python) ED_file_exit(); /* for fsmenu */ UI_exit(); - BKE_blender_userdef_free(&U); + BKE_blender_userdef_free_data(&U); RNA_exit(); /* should be after BPY_python_end so struct python slots are cleared */ |