Fix T48045: Freestyle ID user decrement error.
This fixes reported issue, but there could be more of those hidden in Freestyle code, it did not handle user refcount at all (and the fact it by-passes BKE in some places for efficiency does not help here). Note that this should be relatively harmless, since freestyle uses own Main during render, so everything is cleaned up in the end in any case... But better try to handle IDs correctly here too. :)
This commit is contained in:
parent
f76dec9238
commit
d82d9e14e8
Notes:
blender-bot
2023-02-14 09:09:43 +01:00
Referenced by issue #48045, Freestyle ID user decrement error
|
@ -243,6 +243,8 @@ Material* BlenderStrokeRenderer::GetStrokeShader(Main *bmain, bNodeTree *iNodeTr
|
|||
PointerRNA fromptr, toptr;
|
||||
NodeShaderAttribute *storage;
|
||||
|
||||
id_us_min(&ma->id);
|
||||
|
||||
if (iNodeTree) {
|
||||
// make a copy of linestyle->nodetree
|
||||
ntree = ntreeCopyTree_ex(iNodeTree, bmain, do_id_user);
|
||||
|
@ -514,6 +516,8 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
|
|||
ma->mode |= MA_SHLESS;
|
||||
ma->vcol_alpha = 1;
|
||||
|
||||
id_us_min(&ma->id);
|
||||
|
||||
// Textures
|
||||
while (iStrokeRep->getMTex(a)) {
|
||||
ma->mtex[a] = (MTex *)iStrokeRep->getMTex(a);
|
||||
|
@ -734,6 +738,7 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
|
|||
it != itend; ++it)
|
||||
{
|
||||
mesh->mat[material_index] = (*it)->getMaterial();
|
||||
id_us_plus(&mesh->mat[material_index]->id);
|
||||
|
||||
vector<Strip*>& strips = (*it)->getStrips();
|
||||
for (vector<Strip*>::const_iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
|
||||
|
|
Loading…
Reference in New Issue