From c54df2ad47026a35c2629ba115ced64e7f33a42e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 5 Aug 2015 21:25:28 +1000 Subject: Remove files from recent-files list on failed open --- source/blender/windowmanager/intern/wm_files.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 74be3bc6f5d..24c25fd0eb7 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -398,6 +398,8 @@ void WM_file_autoexec_init(const char *filepath) bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) { + /* assume automated tasks with background, don't write recent file list */ + const bool do_history = (G.background == false) && (CTX_wm_manager(C)->op_undo_depth == 0); bool success = false; int retval; @@ -420,9 +422,6 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) int G_f = G.f; ListBase wmbase; - /* assume automated tasks with background, don't write recent file list */ - 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 */ wm_window_match_init(C, &wmbase); @@ -528,6 +527,19 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) BLI_assert(!"invalid 'retval'"); } + + if (success == false) { + /* remove from recent files list */ + if (do_history) { + RecentFile *recent = BLI_findstring_ptr(&G.recent_files, filepath, offsetof(RecentFile, filepath)); + if (recent) { + MEM_freeN(recent->filepath); + BLI_freelinkN(&G.recent_files, recent); + write_history(); + } + } + } + WM_cursor_wait(0); return success; -- cgit v1.2.3