[Bf-blender-cvs] [bf55eeb] master: Code cleanup: minor changes to custom startup file property use

Campbell Barton noreply at git.blender.org
Sat Nov 30 08:43:18 CET 2013


Commit: bf55eeb2163c3afd12db36b9f48d48d998aa21a2
Author: Campbell Barton
Date:   Sat Nov 30 18:39:55 2013 +1100
http://developer.blender.org/rBbf55eeb2163c3afd12db36b9f48d48d998aa21a2

Code cleanup: minor changes to custom startup file property use

===================================================================

M	source/blender/windowmanager/intern/wm_files.c
M	source/blender/windowmanager/wm_files.h

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index ec86977..dfdbe30 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 0fa0761..5266961 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);




More information about the Bf-blender-cvs mailing list