Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-11-30 11:39:55 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-11-30 11:41:42 +0400
commitbf55eeb2163c3afd12db36b9f48d48d998aa21a2 (patch)
tree788322071179a6e28aabfea0bc0755bb7da2c9b0
parent5910531318c02f0f223ce608dcbe0a6e3232828a (diff)
Code cleanup: minor changes to custom startup file property use
-rw-r--r--source/blender/windowmanager/intern/wm_files.c23
-rw-r--r--source/blender/windowmanager/wm_files.h2
2 files changed, 14 insertions, 11 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;
diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h
index 0fa076131ab..526696138a5 100644
--- a/source/blender/windowmanager/wm_files.h
+++ b/source/blender/windowmanager/wm_files.h
@@ -35,7 +35,7 @@ void wm_read_history(void);
int wm_file_write(struct bContext *C, const char *target, int fileflags, struct ReportList *reports);
int wm_history_read_exec(bContext *C, wmOperator *op);
int wm_homefile_read_exec(struct bContext *C, struct wmOperator *op);
-int wm_homefile_read(struct bContext *C, struct ReportList *reports, short from_memory, const char *filepath);
+int wm_homefile_read(struct bContext *C, struct ReportList *reports, bool from_memory, const char *filepath);
int wm_homefile_write_exec(struct bContext *C, struct wmOperator *op);
int wm_userpref_write_exec(struct bContext *C, struct wmOperator *op);