Cleanup: Change BKE_paint_brush_set
to take in const reference
Some checks failed
Close GitHub Pull Requests / Close Pull Requests (push) Has been cancelled
Some checks failed
Close GitHub Pull Requests / Close Pull Requests (push) Has been cancelled
Changes the overload from accepting `const AssetWeakReference *` to `const AssetWeakReference &` to more strongly indicate proper usage. We should not have a usecase for setting a null `AssetWeakReference` Pull Request: https://projects.blender.org/blender/blender/pulls/144821
This commit is contained in:
@@ -216,7 +216,7 @@ bool BKE_paint_brush_set(Paint *paint, Brush *brush);
|
||||
*/
|
||||
bool BKE_paint_brush_set(Main *bmain,
|
||||
Paint *paint,
|
||||
const AssetWeakReference *brush_asset_reference);
|
||||
const AssetWeakReference &brush_asset_reference);
|
||||
bool BKE_paint_brush_set_default(Main *bmain, Paint *paint);
|
||||
bool BKE_paint_brush_set_essentials(Main *bmain, Paint *paint, const char *name);
|
||||
void BKE_paint_previous_asset_reference_set(Paint *paint,
|
||||
|
@@ -664,7 +664,7 @@ static AssetWeakReference *asset_reference_create_from_brush(Brush *brush)
|
||||
|
||||
bool BKE_paint_brush_set(Main *bmain,
|
||||
Paint *paint,
|
||||
const AssetWeakReference *brush_asset_reference)
|
||||
const AssetWeakReference &brush_asset_reference)
|
||||
{
|
||||
/* Don't resolve this during file read, it will be done after. */
|
||||
if (bmain->is_locked_for_linking) {
|
||||
@@ -672,7 +672,7 @@ bool BKE_paint_brush_set(Main *bmain,
|
||||
}
|
||||
|
||||
Brush *brush = reinterpret_cast<Brush *>(
|
||||
blender::bke::asset_edit_id_from_weak_reference(*bmain, ID_BR, *brush_asset_reference));
|
||||
blender::bke::asset_edit_id_from_weak_reference(*bmain, ID_BR, brush_asset_reference));
|
||||
BLI_assert(brush == nullptr || !ID_IS_LINKED(brush) ||
|
||||
blender::bke::asset_edit_id_is_editable(brush->id));
|
||||
|
||||
@@ -690,8 +690,8 @@ bool BKE_paint_brush_set(Main *bmain,
|
||||
paint->brush_asset_reference = nullptr;
|
||||
if (brush != nullptr) {
|
||||
BLI_assert(blender::bke::asset_edit_weak_reference_from_id(brush->id) ==
|
||||
*brush_asset_reference);
|
||||
paint->brush_asset_reference = MEM_new<AssetWeakReference>(__func__, *brush_asset_reference);
|
||||
brush_asset_reference);
|
||||
paint->brush_asset_reference = MEM_new<AssetWeakReference>(__func__, brush_asset_reference);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -398,13 +398,13 @@ static void toolsystem_brush_activate_from_toolref_for_object_paint(Main *bmain,
|
||||
}();
|
||||
|
||||
if (brush_asset_reference) {
|
||||
BKE_paint_brush_set(bmain, paint, &*brush_asset_reference);
|
||||
BKE_paint_brush_set(bmain, paint, *brush_asset_reference);
|
||||
}
|
||||
}
|
||||
/* Re-activate the main brush, regardless of the brush type. */
|
||||
else {
|
||||
if (paint->tool_brush_bindings.main_brush_asset_reference) {
|
||||
BKE_paint_brush_set(bmain, paint, paint->tool_brush_bindings.main_brush_asset_reference);
|
||||
BKE_paint_brush_set(bmain, paint, *paint->tool_brush_bindings.main_brush_asset_reference);
|
||||
toolsystem_main_brush_binding_update_from_active(paint);
|
||||
}
|
||||
else {
|
||||
@@ -417,7 +417,7 @@ static void toolsystem_brush_activate_from_toolref_for_object_paint(Main *bmain,
|
||||
}();
|
||||
|
||||
if (main_brush_asset_reference) {
|
||||
BKE_paint_brush_set(bmain, paint, &*main_brush_asset_reference);
|
||||
BKE_paint_brush_set(bmain, paint, *main_brush_asset_reference);
|
||||
toolsystem_main_brush_binding_update_from_active(paint);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user