diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-11-30 11:39:55 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-11-30 11:41:42 +0400 |
commit | bf55eeb2163c3afd12db36b9f48d48d998aa21a2 (patch) | |
tree | 788322071179a6e28aabfea0bc0755bb7da2c9b0 /source/blender/windowmanager/intern/wm_files.c | |
parent | 5910531318c02f0f223ce608dcbe0a6e3232828a (diff) |
Code cleanup: minor changes to custom startup file property use
Diffstat (limited to 'source/blender/windowmanager/intern/wm_files.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index ec86977cab9..dfdbe308965 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -519,13 +519,16 @@ void WM_file_read(bContext *C, const char *filepath, ReportList *reports) /* both startup.blend and userpref.blend are checked */ /* the optional paramater custom_file points to an alterntive startup page */ /* custom_file can be NULL */ -int wm_homefile_read(bContext *C, ReportList *reports, short from_memory, const char *custom_file) +int wm_homefile_read(bContext *C, ReportList *reports, bool from_memory, const char *custom_file) { ListBase wmbase; char startstr[FILE_MAX]; char prefstr[FILE_MAX]; int success = 0; + /* options exclude eachother */ + BLI_assert((from_memory && custom_file) == 0); + BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_PRE); G.relbase_valid = 0; @@ -652,15 +655,15 @@ int wm_history_read_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) int wm_homefile_read_exec(bContext *C, wmOperator *op) { - int from_memory = (strcmp(op->type->idname, "WM_OT_read_factory_settings") == 0); - char filepath_buffer[FILE_MAX] = ""; - char *filepath = NULL; - - if (!from_memory) - { - RNA_string_get(op->ptr, "filepath", filepath_buffer); - if (filepath_buffer[0] != '\0') { - filepath = filepath_buffer; + const bool from_memory = (STREQ(op->type->idname, "WM_OT_read_factory_settings")); + char filepath_buf[FILE_MAX]; + const char *filepath = NULL; + + if (!from_memory) { + PropertyRNA *prop = RNA_struct_find_property(op->ptr, "filepath"); + if (RNA_property_is_set(op->ptr, prop)) { + RNA_property_string_get(op->ptr, prop, filepath_buf); + filepath = filepath_buf; if (BLI_access(filepath, R_OK)) { BKE_reportf(op->reports, RPT_ERROR, "Can't read alternative start-up file: '%s'", filepath); return OPERATOR_CANCELLED; |