diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_blendfile.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blendfile.c | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 29 |
3 files changed, 25 insertions, 20 deletions
diff --git a/source/blender/blenkernel/BKE_blendfile.h b/source/blender/blenkernel/BKE_blendfile.h index ac58451e412..1cf8a78fef3 100644 --- a/source/blender/blenkernel/BKE_blendfile.h +++ b/source/blender/blenkernel/BKE_blendfile.h @@ -58,8 +58,7 @@ struct UserDef *BKE_blendfile_userdef_read_from_memory( const void *filebuf, int filelength, struct ReportList *reports); -int BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports); - +bool BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports); /* partial blend file writing */ void BKE_blendfile_write_partial_tag_ID(struct ID *id, bool set); diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 980df05aca2..99e3769572a 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -497,19 +497,22 @@ UserDef *BKE_blendfile_userdef_read_from_memory( } -/* only write the userdef in a .blend */ -int BKE_blendfile_userdef_write(const char *filepath, ReportList *reports) +/** + * Only write the userdef in a .blend + * \return success + */ +bool BKE_blendfile_userdef_write(const char *filepath, ReportList *reports) { Main *mainb = MEM_callocN(sizeof(Main), "empty main"); - int retval = 0; + bool ok = false; if (BLO_write_file(mainb, filepath, G_FILE_USERPREFS, reports, NULL)) { - retval = 1; + ok = true; } MEM_freeN(mainb); - return retval; + return ok; } /** \} */ diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index e991e901bb1..97aa64a8dee 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1472,7 +1472,7 @@ static int wm_userpref_write_exec(bContext *C, wmOperator *op) wmWindowManager *wm = CTX_wm_manager(C); char filepath[FILE_MAX]; const char *cfgdir; - bool ok = false; + bool ok = true; /* update keymaps in user preferences */ WM_keyconfig_update(wm); @@ -1482,31 +1482,34 @@ static int wm_userpref_write_exec(bContext *C, wmOperator *op) printf("trying to save userpref at %s ", filepath); if (BKE_blendfile_userdef_write(filepath, op->reports) != 0) { printf("ok\n"); - ok = true; } else { printf("fail\n"); + ok = false; } } else { BKE_report(op->reports, RPT_ERROR, "Unable to create userpref path"); } - if (U.app_template[0] && (cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, U.app_template))) { - /* Also save app-template prefs */ - BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL); - printf("trying to save app-template userpref at %s ", filepath); - if (BKE_blendfile_userdef_write(filepath, op->reports) == 0) { - printf("fail\n"); - ok = true; + if (U.app_template[0]) { + if ((cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, U.app_template))) { + /* Also save app-template prefs */ + BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL); + printf("trying to save app-template userpref at %s ", filepath); + if (BKE_blendfile_userdef_write(filepath, op->reports) != 0) { + printf("ok\n"); + } + else { + printf("fail\n"); + ok = false; + } } else { - printf("ok\n"); + BKE_report(op->reports, RPT_ERROR, "Unable to create app-template userpref path"); + ok = false; } } - else if (U.app_template[0]) { - BKE_report(op->reports, RPT_ERROR, "Unable to create app-template userpref path"); - } return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } |