[Bf-blender-cvs] [3cd93ace247] temp-asset-library-all: Simple progress reporting for all library

Julian Eisel noreply at git.blender.org
Wed Dec 7 18:30:45 CET 2022


Commit: 3cd93ace247fefff8dec69879bb61ed074d55495
Author: Julian Eisel
Date:   Wed Dec 7 18:29:38 2022 +0100
Branches: temp-asset-library-all
https://developer.blender.org/rB3cd93ace247fefff8dec69879bb61ed074d55495

Simple progress reporting for all library

Progress bar display the file reading (and other operations) is actually
broken in master for a while, so this won't actually be reported. Still
calculate it for once it's fixed.

===================================================================

M	source/blender/editors/space_file/filelist.cc

===================================================================

diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc
index 234c550d829..44f846f8595 100644
--- a/source/blender/editors/space_file/filelist.cc
+++ b/source/blender/editors/space_file/filelist.cc
@@ -3900,10 +3900,14 @@ static void filelist_readjob_all_asset_library(FileListReadJob *job_params,
   if (job_params->only_main_data) {
     return;
   }
-  /* TODO propertly update progress? */
+
+  /* Count how many asset libraries need to be loaded, for progress reporting. Not very precise. */
+  int library_count = 0;
+  asset_system::AssetLibrary::foreach_loaded([&library_count](auto &) { library_count++; }, false);
 
   BLI_assert(filelist->asset_library != nullptr);
 
+  int libraries_done_count = 0;
   /* The "All" asset library was loaded, which means all other asset libraries are also loaded.
    * Load their assets from disk into the "All" library. */
   asset_system::AssetLibrary::foreach_loaded(
@@ -3917,7 +3921,12 @@ static void filelist_readjob_all_asset_library(FileListReadJob *job_params,
         job_params->load_asset_library = &nested_library;
         BLI_strncpy(filelist->filelist.root, root_path.c_str(), sizeof(filelist->filelist.root));
 
-        filelist_readjob_recursive_dir_add_items(true, job_params, stop, do_update, progress);
+        float progress_this = 0.0f;
+        filelist_readjob_recursive_dir_add_items(
+            true, job_params, stop, do_update, &progress_this);
+
+        libraries_done_count++;
+        *progress = float(libraries_done_count) / library_count;
       },
       false);
 }



More information about the Bf-blender-cvs mailing list