Brush Assets: Make revert and delete operators affect dependencies #119806

Merged
Brecht Van Lommel merged 2 commits from brecht/blender:brush-revert-delete-all into brush-assets-project 2024-03-25 14:34:55 +01:00
2 changed files with 6 additions and 2 deletions
Showing only changes of commit 6c9744feee - Show all commits

View File

@ -152,6 +152,9 @@ struct AssetWeakReferenceMain {
}
AssetWeakReferenceMain &operator=(AssetWeakReferenceMain &&other)
{
if (this == &other) {
brecht marked this conversation as resolved Outdated

I think this needs a this == &other check

I think this needs a `this == &other` check
return *this;
}
this->filepath = std::exchange(other.filepath, "");
this->main = std::exchange(other.main, nullptr);
return *this;
@ -183,7 +186,7 @@ void AssetWeakReferenceMain::reload(Main &global_main)
brecht marked this conversation as resolved
Review

to be append -> to be appended

`to be append` -> `to be appended`
BKE_blendfile_link_append_context_library_add(lapp_context, this->filepath.c_str(), nullptr);
/* Requests all existing datablocks to be append again. */
/* Requests all existing datablocks to be appended again. */
ID *old_id;
FOREACH_MAIN_ID_BEGIN (old_main, old_id) {
ID_Type old_id_code = GS(old_id->name);

View File

@ -1361,7 +1361,8 @@ static int brush_asset_revert_exec(bContext *C, wmOperator * /*op*/)
Brush *brush = BKE_paint_brush(paint);
Main *asset_main = BKE_main_from_id(bmain, &brush->id);
/* Reload entire main, including texture dependencies. */
/* Reload entire main, including texture dependencies. This relies on there
brecht marked this conversation as resolved Outdated

I'd add a comment here that this relies on a single brush asset stored per file

I'd add a comment here that this relies on a single brush asset stored per file
* being only a single brush asset per blend file. */
BKE_asset_weak_reference_main_reload(*bmain, *asset_main);
WM_main_add_notifier(NC_BRUSH | NA_EDITED, nullptr);