Fix T94692: Show Cached OneDrive Thumbnails

When OneDrive files are offline, show preexisting thumbnails.

See D13930 for details.

Differential Revision: https://developer.blender.org/D13930

Reviewed by Julian Eisel
This commit is contained in:
Harley Acheson 2022-03-11 10:04:24 -08:00
parent 22807d2075
commit bd9f94e917
Notes: blender-bot 2023-09-08 16:42:41 +02:00
Referenced by issue #94692, Thumbnails are not shown for offline files in OneDrive
Referenced by pull request #112101, Thumbnails: Always use cached thumbnails for offline files
Referenced by commit 3589533908, Thumbnails: Always use cached thumbnails for offline files
1 changed files with 6 additions and 8 deletions

View File

@ -339,7 +339,7 @@ typedef struct FileListEntryPreview {
char path[FILE_MAX];
uint flags;
int index;
int attributes; /* from FileDirEntry. */
int icon_id;
} FileListEntryPreview;
@ -1623,8 +1623,10 @@ static void filelist_cache_preview_runf(TaskPool *__restrict pool, void *taskdat
IMB_thumb_path_lock(preview->path);
/* Always generate biggest preview size for now, it's simpler and avoids having to re-generate
* in case user switch to a bigger preview size. */
ImBuf *imbuf = IMB_thumb_manage(preview->path, THB_LARGE, source);
* in case user switch to a bigger preview size. Do not create preview when file is offline. */
ImBuf *imbuf = (preview->attributes & FILE_ATTR_OFFLINE) ?
IMB_thumb_read(preview->path, THB_LARGE) :
IMB_thumb_manage(preview->path, THB_LARGE, source);
IMB_thumb_path_unlock(preview->path);
if (imbuf) {
preview->icon_id = BKE_icon_imbuf_create(imbuf);
@ -1704,11 +1706,6 @@ static void filelist_cache_previews_push(FileList *filelist, FileDirEntry *entry
BLI_assert(cache->flags & FLC_PREVIEWS_ACTIVE);
if (!entry->preview_icon_id && (entry->attributes & FILE_ATTR_OFFLINE)) {
entry->flags |= FILE_ENTRY_INVALID_PREVIEW;
return;
}
if (entry->preview_icon_id) {
return;
}
@ -1735,6 +1732,7 @@ static void filelist_cache_previews_push(FileList *filelist, FileDirEntry *entry
FileListEntryPreview *preview = MEM_mallocN(sizeof(*preview), __func__);
preview->index = index;
preview->flags = entry->typeflag;
preview->attributes = entry->attributes;
preview->icon_id = 0;
if (preview_in_memory) {