From 8c688a052c79e006b586598d2ac55a550cea3550 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 29 Jan 2014 05:33:05 +1100 Subject: File Reading: add wrapper function for WM_file_read also return cancelled when an operator fails to load a file --- source/blender/windowmanager/intern/wm_files.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/windowmanager/intern/wm_files.c') diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index b99246dc34b..7bbf78ef089 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -388,8 +388,9 @@ void WM_file_autoexec_init(const char *filepath) } } -void WM_file_read(bContext *C, const char *filepath, ReportList *reports) +bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) { + bool success = false; int retval; /* so we can get the error message */ @@ -412,7 +413,7 @@ void WM_file_read(bContext *C, const char *filepath, ReportList *reports) ListBase wmbase; /* assume automated tasks with background, don't write recent file list */ - const int do_history = (G.background == FALSE) && (CTX_wm_manager(C)->op_undo_depth == 0); + const bool do_history = (G.background == FALSE) && (CTX_wm_manager(C)->op_undo_depth == 0); /* put aside screens to match with persistent windows later */ /* also exit screens and editors */ @@ -496,6 +497,8 @@ void WM_file_read(bContext *C, const char *filepath, ReportList *reports) BKE_reset_undo(); BKE_write_undo(C, "original"); /* save current state */ + + success = true; } else if (retval == BKE_READ_EXOTIC_OK_OTHER) BKE_write_undo(C, "Import file"); @@ -516,6 +519,8 @@ void WM_file_read(bContext *C, const char *filepath, ReportList *reports) WM_cursor_wait(0); + return success; + } -- cgit v1.2.3