Fix #135328: Grease Pencil: Unable to set default eraser

Incorrectly changed in 9e8c037375.

The Grease Pencil `eraser_brush` property is still accessed and set
directly from Python, we cannot remove setting access to the property in
favor of the `AssetWeakReference` without first making other changes.
For now, this patch re-adds the RNA definitions for the property to make
it editable again.

Pull Request: https://projects.blender.org/blender/blender/pulls/135743
This commit is contained in:
Sean Kim
2025-03-10 16:28:50 +01:00
committed by Falk David
parent 05ec635e6b
commit 4d50e00914

View File

@@ -289,6 +289,14 @@ static PointerRNA rna_Paint_eraser_brush_get(PointerRNA *ptr)
return RNA_id_pointer_create(&brush->id);
}
static void rna_Paint_eraser_brush_set(PointerRNA *ptr, PointerRNA value, ReportList * /*reports*/)
{
Paint *paint = static_cast<Paint *>(ptr->data);
Brush *brush = static_cast<Brush *>(value.data);
BKE_paint_eraser_brush_set(paint, brush);
BKE_paint_invalidate_overlay_all();
}
static bool rna_Paint_eraser_brush_poll(PointerRNA *ptr, PointerRNA value)
{
const Paint *paint = static_cast<Paint *>(ptr->data);
@@ -542,10 +550,13 @@ static void rna_def_paint(BlenderRNA *brna)
"the last used brush on file load");
prop = RNA_def_property(srna, "eraser_brush", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "Brush");
RNA_def_property_pointer_funcs(
prop, "rna_Paint_eraser_brush_get", nullptr, nullptr, "rna_Paint_eraser_brush_poll");
RNA_def_property_pointer_funcs(prop,
"rna_Paint_eraser_brush_get",
"rna_Paint_eraser_brush_set",
nullptr,
"rna_Paint_eraser_brush_poll");
RNA_def_property_ui_text(prop,
"Default Eraser Brush",
"Default eraser brush for quickly alternating with the main brush");