Fix part of T89313: Attribute search crash during animation playback

During animation playback, data-blocks are reallocated, so storing
pointers to the resulting data is not okay. Instead, the data should
be retrieved from the context. This works when the applied search
item is the "dummy" item added for non-matches. However, it still
crashes for every other item, because the memory is owned by the
modifier value log, which has been freed by the time the exec function
runs.

The next part of the solution is to allow uiSearchItems
to own memory for the search items.
This commit is contained in:
2021-11-05 11:19:12 -05:00
parent 594ee5f160
commit c473b2ce8b
3 changed files with 79 additions and 33 deletions

View File

@@ -163,7 +163,7 @@ void BLI_libblock_ensure_unique_name(struct Main *bmain, const char *name) ATTR_
struct ID *BKE_libblock_find_name(struct Main *bmain,
const short type,
const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
struct ID *BKE_libblock_find_session_uuid(struct Main *bmain, short type, uint32_t session_uuid);
/**
* Duplicate (a.k.a. deep copy) common processing options.
* See also eDupli_ID_Flags for options controlling what kind of IDs to duplicate.

View File

@@ -1375,6 +1375,20 @@ ID *BKE_libblock_find_name(struct Main *bmain, const short type, const char *nam
return BLI_findstring(lb, name, offsetof(ID, name) + 2);
}
struct ID *BKE_libblock_find_session_uuid(Main *bmain,
const short type,
const uint32_t session_uuid)
{
ListBase *lb = which_libbase(bmain, type);
BLI_assert(lb != NULL);
LISTBASE_FOREACH (ID *, id, lb) {
if (id->session_uuid == session_uuid) {
return id;
}
}
return NULL;
}
/**
* Sort given \a id into given \a lb list, using case-insensitive comparison of the id names.
*