diff options
author | Bastien Montagne <bastien@blender.org> | 2020-11-03 14:09:00 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-11-03 14:09:00 +0300 |
commit | bc0a6b0400ceeda971384bd88014ea7eb6007ad0 (patch) | |
tree | 2e3bfdf0b76b6a57cf9ce7dcb0700a0c2923e533 /source/blender/blenkernel/intern/paint.c | |
parent | 5610ccdc080497042a24592432ade575e2fab489 (diff) |
Fix T71759: Sculpt/Vertex/Weight Paint Brush Size Gets Undone After Undoing a Stroke.
Add code preserving scene's toolsettings accross undo.
IDPointers are dealt with special care, we try to keep existing ones for
some (like brushes) when possible.
Note that this covers ToolSettings, Brushes and Palettes currently.
I'm not especially happy about how this new code mixes with existing
'foreach_id' one, in particular in scene. But cannot think of a better,
more generic way to do it currently.
Maniphest Tasks: T71759
Differential Revision: https://developer.blender.org/D9311
Diffstat (limited to 'source/blender/blenkernel/intern/paint.c')
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 37637e30d9e..f2af5520d16 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -125,6 +125,16 @@ static void palette_blend_read_data(BlendDataReader *reader, ID *id) BLO_read_list(reader, &palette->colors); } +static void palette_undo_preserve(BlendLibReader *UNUSED(reader), ID *id_new, ID *id_old) +{ + /* Whole Palette is preserved accross undo's, and it has no extra pointer, simple. */ + /* Note: We do not care about potential internal references to self here, Palette has none. */ + /* Note: We do not swap IDProperties, as dealing with potential ID pointers in those would be + * fairly delicate. */ + BKE_lib_id_swap(NULL, id_new, id_old); + SWAP(IDProperty *, id_new->properties, id_old->properties); +} + IDTypeInfo IDType_ID_PAL = { .id_code = ID_PAL, .id_filter = FILTER_ID_PAL, @@ -147,7 +157,7 @@ IDTypeInfo IDType_ID_PAL = { .blend_read_lib = NULL, .blend_read_expand = NULL, - .blend_read_undo_preserve = NULL, + .blend_read_undo_preserve = palette_undo_preserve, }; static void paint_curve_copy_data(Main *UNUSED(bmain), |