diff options
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index e65156167a9..7c608e2115d 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -2784,33 +2784,30 @@ void FILE_OT_rename(struct wmOperatorType *ot) static bool file_delete_poll(bContext *C) { - bool poll = ED_operator_file_active(C); + if (!ED_operator_file_active(C)) { + return false; + } + SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_active_params(sfile); + if (!sfile || !params) { + return false; + } - if (sfile && params) { - char dir[FILE_MAX_LIBEXTRA]; - int numfiles = filelist_files_ensure(sfile->files); - int i; - int num_selected = 0; + char dir[FILE_MAX_LIBEXTRA]; + if (filelist_islibrary(sfile->files, dir, NULL)) { + return false; + } - if (filelist_islibrary(sfile->files, dir, NULL)) { - poll = 0; - } - for (i = 0; i < numfiles; i++) { - if (filelist_entry_select_index_get(sfile->files, i, CHECK_ALL)) { - num_selected++; - } - } - if (num_selected <= 0) { - poll = 0; + int numfiles = filelist_files_ensure(sfile->files); + for (int i = 0; i < numfiles; i++) { + if (filelist_entry_select_index_get(sfile->files, i, CHECK_ALL)) { + /* Has a selected file -> the operator can run. */ + return true; } } - else { - poll = 0; - } - return poll; + return false; } static bool file_delete_single(const FileSelectParams *params, |