Commit: d82d9e14e8194f2594718276bcc7bde415323344
Author: Bastien Montagne
Date:   Mon Apr 4 15:43:45 2016 +0200
Branches: master
https://developer.blender.org/rBd82d9e14e8194f2594718276bcc7bde415323344

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. :)

===================================================================

M       
source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp

===================================================================

diff --git 
a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp 
b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index 7c10591..5c361de 100644
--- 
a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ 
b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -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) {

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to