Merge branch 'master' into blender2.8
authorBastien Montagne <montagne29@wanadoo.fr>
Tue, 14 Aug 2018 12:10:47 +0000 (14:10 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 14 Aug 2018 12:10:47 +0000 (14:10 +0200)
source/blender/blenkernel/intern/object.c
source/blender/editors/object/object_add.c

index 41c23c46c44f669611b6a13ca7d602e13d378a6b..b4060d6e60a9b691443cfd92a3d5c33e9b8f4ba0 100644 (file)
@@ -1246,6 +1246,12 @@ void BKE_object_copy_data(Main *bmain, Object *ob_dst, const Object *ob_src, con
                ob_dst->matbits = MEM_dupallocN(ob_src->matbits);
                ob_dst->totcol = ob_src->totcol;
        }
+       else if (ob_dst->mat != NULL || ob_dst->matbits != NULL) {
+               /* This shall not be needed, but better be safe than sorry. */
+               BLI_assert(!"Object copy: non-NULL material pointers with zero counter, should not happen.");
+               ob_dst->mat = NULL;
+               ob_dst->matbits = NULL;
+       }
 
        if (ob_src->iuser) ob_dst->iuser = MEM_dupallocN(ob_src->iuser);
 
index f41c4071634a9929dcb35927d4b0ef2641fe25a5..8b4412ed6f97f12d03a0db0efbc698102d4416d3 100644 (file)
@@ -2098,6 +2098,9 @@ static int convert_exec(bContext *C, wmOperator *op)
                        continue;
                }
 
+               /* Ensure new object has consistent material data with its new obdata. */
+               test_object_materials(bmain, newob, newob->data);
+
                /* tag obdata if it was been changed */
 
                /* If the original object is active then make this object active */