diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-08-05 14:25:28 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-08-05 14:26:10 +0300 |
commit | c54df2ad47026a35c2629ba115ced64e7f33a42e (patch) | |
tree | 206961ea23c203ccee0d7a46d8d4065e67141f08 /source/blender/windowmanager/intern/wm_files.c | |
parent | cae25ff2404cf197b3bf0ca2271880d18dfa4660 (diff) |
Remove files from recent-files list on failed open
Diffstat (limited to 'source/blender/windowmanager/intern/wm_files.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 18 |
1 files changed, 15 insertions, 3 deletions
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; |