From 2026e6a7b3f1aa94a61ea03bdbc9ede6cdc1b55a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 25 May 2013 00:23:23 +0000 Subject: fix [#35500] Material Copy Crash on specific scenes check material textures exist before using in a pasted material. --- source/blender/blenkernel/intern/material.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 2b7a41933b4..c8cd65e9477 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1597,7 +1597,15 @@ void paste_matcopybuf(Material *ma) mtex = ma->mtex[a]; if (mtex) { ma->mtex[a] = MEM_dupallocN(mtex); - if (mtex->tex) id_us_plus((ID *)mtex->tex); + if (mtex->tex) { + /* first check this is in main (we may have loaded another file) [#35500] */ + if (BLI_findindex(&G.main->tex, mtex->tex) != -1) { + id_us_plus((ID *)mtex->tex); + } + else { + ma->mtex[a]->tex = NULL; + } + } } } -- cgit v1.2.3