mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Fix: Undoing across mode boundaries can leave invalid SculptSession
Introduced with 9407047c63
After introducing the cached management of `SculptSession` with memfile
undo, the pointer is restored between all memfile steps, even when the
mode that the `SculptSession` was created in does not match the mode of
the underlying object.
To prevent this mismatch and potential unwanted data sharing, check for
this match and clear the `SculptSession` if needed. In the future, more
data may be able to be shared across modes, but that was not the intent
of the original PR.
Pull Request: https://projects.blender.org/blender/blender/pulls/162480
This commit is contained in:
parent
986f55b332
commit
0d4181196c
1 changed files with 10 additions and 4 deletions
|
|
@ -1148,10 +1148,16 @@ static void object_blend_read_after_liblink(BlendLibReader *reader, ID *id)
|
|||
/* When loading undo steps, for objects in modes that use `sculpt_session`, recreate the mode
|
||||
* runtime data. For regular non-undo reading, this is currently handled by mode switching after
|
||||
* the initial file read. */
|
||||
if (BLO_read_lib_is_undo(reader) && ob->mode & OB_MODE_ALL_SCULPT &&
|
||||
ob->runtime->sculpt_session == nullptr)
|
||||
{
|
||||
BKE_object_sculpt_data_create(ob);
|
||||
if (BLO_read_lib_is_undo(reader) && ob->mode & OB_MODE_ALL_SCULPT) {
|
||||
/* The runtime may have been created in a non-matching mode and should be deleted here. */
|
||||
if (ob->runtime->sculpt_session != nullptr &&
|
||||
ob->runtime->sculpt_session->mode_type != ob->mode)
|
||||
{
|
||||
BKE_sculptsession_free(ob);
|
||||
}
|
||||
if (ob->runtime->sculpt_session == nullptr) {
|
||||
BKE_object_sculpt_data_create(ob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue