Fix for assert failure in material preview

All localized datablocks are not supposed to have animation
data associated with them.

There was an easy way to reproduce assert failure: toggle
animation decorator for Viewport Display -> Color.
This commit is contained in:
Sergey Sharybin 2018-12-04 12:30:24 +01:00
parent e6141d7b3b
commit 3d013f7b10
Notes: blender-bot 2023-02-14 11:00:17 +01:00
Referenced by issue #58723, EnumProperty with 'ENUM_FLAG'  option does not trigger operator redo
6 changed files with 16 additions and 4 deletions

View File

@ -93,6 +93,8 @@ void BKE_libblock_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r
void *BKE_libblock_copy(struct Main *bmain, const struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
/* "Deprecated" old API. */
void *BKE_libblock_copy_nolib(const struct ID *id, const bool do_action) ATTR_NONNULL();
/* Special version. sued by datablock localization. */
void *BKE_libblock_copy_for_localize(const struct ID *id);
void BKE_libblock_rename(struct Main *bmain, struct ID *id, const char *name) ATTR_NONNULL();
void BLI_libblock_ensure_unique_name(struct Main *bmain, const char *name) ATTR_NONNULL();

View File

@ -150,7 +150,7 @@ Lamp *BKE_lamp_localize(Lamp *la)
*
* NOTE: Only possible once nested node trees are fully converted to that too. */
Lamp *lan = BKE_libblock_copy_nolib(&la->id, false);
Lamp *lan = BKE_libblock_copy_for_localize(&la->id);
lan->curfalloff = curvemapping_copy(la->curfalloff);

View File

@ -1362,6 +1362,16 @@ void *BKE_libblock_copy_nolib(const ID *id, const bool do_action)
return idn;
}
void *BKE_libblock_copy_for_localize(const ID *id)
{
ID *idn;
BKE_libblock_copy_ex(NULL, id, &idn, (LIB_ID_CREATE_NO_MAIN |
LIB_ID_CREATE_NO_USER_REFCOUNT |
LIB_ID_COPY_ACTIONS |
LIB_ID_COPY_NO_ANIMDATA));
return idn;
}
void BKE_library_free(Library *lib)
{
if (lib->packedfile)

View File

@ -235,7 +235,7 @@ Material *BKE_material_localize(Material *ma)
*
* NOTE: Only possible once nested node trees are fully converted to that too. */
Material *man = BKE_libblock_copy_nolib(&ma->id, false);
Material *man = BKE_libblock_copy_for_localize(&ma->id);
man->texpaintslot = NULL;
man->preview = NULL;

View File

@ -476,7 +476,7 @@ Tex *BKE_texture_localize(Tex *tex)
Tex *texn;
texn = BKE_libblock_copy_nolib(&tex->id, false);
texn = BKE_libblock_copy_for_localize(&tex->id);
/* image texture: BKE_texture_free also doesn't decrease */

View File

@ -154,7 +154,7 @@ World *BKE_world_localize(World *wrld)
World *wrldn;
wrldn = BKE_libblock_copy_nolib(&wrld->id, false);
wrldn = BKE_libblock_copy_for_localize(&wrld->id);
if (wrld->nodetree)
wrldn->nodetree = ntreeLocalize(wrld->nodetree);