WIP: Brush assets project #106303

Draft
Julian Eisel wants to merge 370 commits from brush-assets-project into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
4 changed files with 12 additions and 5 deletions
Showing only changes of commit c0eacdb574 - Show all commits

View File

@ -125,13 +125,12 @@ TEST_F(AssetRepresentationTest, weak_reference__compare)
asset_library_root_); asset_library_root_);
AssetRepresentation &asset = add_dummy_asset(*library, "path/to/an/asset"); AssetRepresentation &asset = add_dummy_asset(*library, "path/to/an/asset");
AssetWeakReference *weak_ref = asset.make_weak_reference(); AssetWeakReference weak_ref = asset.make_weak_reference();
AssetWeakReference other; AssetWeakReference other;
other.asset_library_type = ASSET_LIBRARY_CUSTOM; other.asset_library_type = ASSET_LIBRARY_CUSTOM;
other.asset_library_identifier = "My custom lib"; other.asset_library_identifier = "My custom lib";
other.relative_asset_identifier = "path/to/an/asset"; other.relative_asset_identifier = "path/to/an/asset";
EXPECT_EQ(*weak_ref, other); EXPECT_EQ(weak_ref, other);
BKE_asset_weak_reference_free(&weak_ref);
/* Make the destructor work. */ /* Make the destructor work. */
other.asset_library_identifier = nullptr; other.asset_library_identifier = nullptr;

View File

@ -30,6 +30,13 @@ AssetWeakReference::AssetWeakReference()
{ {
} }
AssetWeakReference::AssetWeakReference(const AssetWeakReference &other)
: asset_library_type(other.asset_library_type),
asset_library_identifier(BLI_strdup_null(other.asset_library_identifier)),
relative_asset_identifier(BLI_strdup_null(other.relative_asset_identifier))
{
}
AssetWeakReference::AssetWeakReference(AssetWeakReference &&other) AssetWeakReference::AssetWeakReference(AssetWeakReference &&other)
: asset_library_type(other.asset_library_type), : asset_library_type(other.asset_library_type),
asset_library_identifier(other.asset_library_identifier), asset_library_identifier(other.asset_library_identifier),

View File

@ -740,6 +740,7 @@ void BKE_paint_brush_asset_restore(Main *bmain, Paint *paint)
AssetWeakReference weak_ref = std::move(*paint->brush_asset_reference); AssetWeakReference weak_ref = std::move(*paint->brush_asset_reference);
MEM_delete(paint->brush_asset_reference); MEM_delete(paint->brush_asset_reference);
paint->brush_asset_reference = nullptr;
Brush *brush_asset = BKE_brush_asset_runtime_ensure(bmain, weak_ref); Brush *brush_asset = BKE_brush_asset_runtime_ensure(bmain, weak_ref);

View File

@ -178,10 +178,10 @@ typedef struct AssetWeakReference {
#ifdef __cplusplus #ifdef __cplusplus
AssetWeakReference(); AssetWeakReference();
AssetWeakReference(const AssetWeakReference &);
AssetWeakReference(AssetWeakReference &&); AssetWeakReference(AssetWeakReference &&);
AssetWeakReference(const AssetWeakReference &) = delete;
~AssetWeakReference();
AssetWeakReference &operator=(AssetWeakReference &&); AssetWeakReference &operator=(AssetWeakReference &&);
~AssetWeakReference();
bool operator==(const AssetWeakReference &other) const; bool operator==(const AssetWeakReference &other) const;
bool operator!=(const AssetWeakReference &other) const; bool operator!=(const AssetWeakReference &other) const;