Texture preview render now doesn't increment/decrement material->texture
user counts anymore. Blenders library.c code could use some overhaul
once to support data relinkage and copying around better. :)
This commit is contained in:
2011-04-04 13:47:34 +00:00
parent 36858f6342
commit f2fd9d11bc
2 changed files with 10 additions and 2 deletions

View File

@@ -245,12 +245,11 @@ Material *localize_material(Material *ma)
man= copy_libblock(ma);
BLI_remlink(&G.main->mat, man);
/* no increment for texture ID users, in previewrender.c it prevents decrement */
for(a=0; a<MAX_MTEX; a++) {
if(ma->mtex[a]) {
man->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial");
memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex));
/* free_material decrements! */
id_us_plus((ID *)man->mtex[a]->tex);
}
}

View File

@@ -1117,11 +1117,20 @@ static void shader_preview_free(void *customdata)
if(sp->matcopy) {
struct IDProperty *properties;
int a;
/* node previews */
shader_preview_updatejob(sp);
/* get rid of copied material */
BLI_remlink(&pr_main->mat, sp->matcopy);
/* free_material decrements texture, prevent this. hack alert! */
for(a=0; a<MAX_MTEX; a++) {
MTex *mtex= sp->matcopy->mtex[a];
if(mtex && mtex->tex) mtex->tex= NULL;
}
free_material(sp->matcopy);
properties= IDP_GetProperties((ID *)sp->matcopy, FALSE);