Page MenuHome

Make "Remove from recent files when error/file not found" optional by user preference
Needs ReviewPublic

Authored by Roel Koster (kostex) on May 16 2019, 10:00 AM.

Details

Summary

In my working environment it regularly happens that network shares are temporarily unavailable.
When opening a file in Blender from an unavailable share, it will be removed from recent files.

I think this is too destructive!

This should be optional or removed completely (or seperate as a user initiated clean up action).

Here is a proposal to make it optional via user preference.
I hope you understand the importance.

Regards,
Roel

Diff Detail

Repository
rB Blender

Event Timeline

Brecht Van Lommel (brecht) requested changes to this revision.May 17 2019, 12:08 PM

We could automatically hide missing files from the menu instead of permanently removing. We should only add preferences if we can't find an automatic solution.

This revision now requires changes to proceed.May 17 2019, 12:08 PM
Roel Koster (kostex) updated this revision to Diff 15411.EditedMay 17 2019, 12:50 PM

Recent files are not shown now when not available..
I would like to hide them instead of not showing them, to make it more clear.. but I'm too dumb to find a way (yet)
Any hints would be nice ;-)

Roel Koster (kostex) updated this revision to Diff 15413.EditedMay 17 2019, 1:01 PM

it was right under my eyes.. ;-)

except for maybe letting the user highlight the item and let it fail the loading when selected, otherwise you'll never be able to actually remove a non existing file anymore.
again any tip would be good..
so a hidden but selectable item.. is that even possible? otherwise, maybe a good idea is too just add : (unavailable) next to the name instead of hiding/ghosting it?

Option 2: Adding a (N/A) to unavailable files

static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu)
{
  struct RecentFile *recent;
  uiLayout *layout = menu->layout;
  uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
  if (!BLI_listbase_is_empty(&G.recent_files)) {
    for (recent = G.recent_files.first; (recent); recent = recent->next) {
      const char *file = BLI_path_basename(recent->filepath);
      const int icon = BLO_has_bfile_extension(file) ? ICON_FILE_BLEND : ICON_FILE_BACKUP;
      PointerRNA ptr;
      if (!BLI_exists(recent->filepath)){
        char file_na[strlen(file) + 7];
        strcpy(file_na, file);
        strcat(file_na, " (N/A)");
        uiItemFullO(layout, "WM_OT_open_mainfile", file_na, icon, NULL, WM_OP_INVOKE_DEFAULT, 0, &ptr);
      }
      else {
        uiItemFullO(layout, "WM_OT_open_mainfile", file, icon, NULL, WM_OP_INVOKE_DEFAULT, 0, &ptr);
      }
      RNA_string_set(&ptr, "filepath", recent->filepath);
      RNA_boolean_set(&ptr, "display_file_selector", false);
    }
  }
  else {
    uiItemL(layout, IFACE_("No Recent Files"), ICON_NONE);
  }
}
Brecht Van Lommel (brecht) requested changes to this revision.May 18 2019, 10:10 AM

You're saying Blender removes files from the recent files list when they are unavailable. But this patch contains no code to disable that behavior?

As far as I can tell that code was removed in rB01a8216a4bc8: Disable check for recent-files.txt existing..

We can't run BLI_exists() in user interface drawing code. It can hang for several seconds for network drivers in some cases.

This revision now requires changes to proceed.May 18 2019, 10:10 AM

The DIFF I've submitted is to make unavailable files a uiItemL() so unselectable. (But that behaviour is unwanted because then you'll never be able to remove a really non existing recent file from the list)
The option 2 is the one where we only make the user aware that the file is (temporarily) unavailable..

But both rely on BLI_exists so if that is not approved, I don't see a way to solve the issue.. maybe close it and I'll just patch my own branch (with the preference option.. I like it ;-)

Or another approach is like the recent FOLDERS to have a "Cleanup" menu in the open recent file menu.. but that is too complex for me to code

Succeeded in kitbashing a Cleanup Menu ;-)
Maybe this approach gets your liking? Cleanup/Pro-i-fy my code, but my main purpose was to show effort and circumvent using BLI_exists in the interface drawing.