Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2021-10-19 19:07:22 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-10-19 19:07:22 +0300
commit823996b0342b7352fc5b2e24eceb6204612438cd (patch)
tree08dca1ce5386c2b06ab01fad1f2f1ac5c236047a /source/blender/blenkernel/BKE_asset_catalog.hh
parentb6c3b41d413813d8059476f2c0357b7a4e51ad22 (diff)
Asset Browser: Improved workflow for asset catalog saving
No longer save asset catalogs on blendfile save. Instead: - extend the confirmation prompt for unsaved changes to show unsaved catalogs. - In the confirmation prompt, make catalog saving explicit & optional, just like we do it for external images. {F10881736} - In the Asset Browser catalog tree, show an operator icon to save the catalogs to disk. It's grayed out if there are no changes to save, or if the .blend wasn't saved yet (required to know where to save the catalog definitions to). {F10881743} Much of the work was done by @Severin and reviewed by me, then we swapped roles. Reviewed By: Severin Differential Revision: https://developer.blender.org/D12796
Diffstat (limited to 'source/blender/blenkernel/BKE_asset_catalog.hh')
-rw-r--r--source/blender/blenkernel/BKE_asset_catalog.hh17
1 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_asset_catalog.hh b/source/blender/blenkernel/BKE_asset_catalog.hh
index d5c8acff960..f7896e0f51e 100644
--- a/source/blender/blenkernel/BKE_asset_catalog.hh
+++ b/source/blender/blenkernel/BKE_asset_catalog.hh
@@ -63,13 +63,21 @@ class AssetCatalogService {
AssetCatalogService();
explicit AssetCatalogService(const CatalogFilePath &asset_library_root);
+ /**
+ * Set global tag indicating that some catalog modifications are unsaved that could get lost
+ * on exit. This tag is not set by internal catalog code, the catalog service user is responsible
+ * for it. It is cleared by #write_to_disk().
+ */
+ void tag_has_unsaved_changes();
+ bool has_unsaved_changes() const;
+
/** Load asset catalog definitions from the files found in the asset library. */
void load_from_disk();
/** Load asset catalog definitions from the given file or directory. */
void load_from_disk(const CatalogFilePath &file_or_directory_path);
/**
- * Write the catalog definitions to disk in response to the blend file being saved.
+ * Write the catalog definitions to disk.
*
* The location where the catalogs are saved is variable, and depends on the location of the
* blend file. The first matching rule wins:
@@ -85,7 +93,7 @@ class AssetCatalogService {
*
* Return true on success, which either means there were no in-memory categories to save,
* or the save was successful. */
- bool write_to_disk_on_blendfile_save(const CatalogFilePath &blend_file_path);
+ bool write_to_disk(const CatalogFilePath &blend_file_path);
/**
* Merge on-disk changes into the in-memory asset catalogs.
@@ -166,10 +174,15 @@ class AssetCatalogService {
Vector<std::unique_ptr<AssetCatalogCollection>> undo_snapshots_;
Vector<std::unique_ptr<AssetCatalogCollection>> redo_snapshots_;
+ bool has_unsaved_changes_ = false;
void load_directory_recursive(const CatalogFilePath &directory_path);
void load_single_file(const CatalogFilePath &catalog_definition_file_path);
+ /** Implementation of #write_to_disk() that doesn't clear the "has unsaved changes" tag. */
+ bool write_to_disk_ex(const CatalogFilePath &blend_file_path);
+ void untag_has_unsaved_changes();
+
std::unique_ptr<AssetCatalogDefinitionFile> parse_catalog_file(
const CatalogFilePath &catalog_definition_file_path);