Merge branch 'master' into blender2.8
[blender.git] / source / blender / blenkernel / intern / idprop.c
index 65d3f9e93fce900dc8aa5eb46a1ac30d11be25ab..769a14607003a4691a081952876102f5b7973d28 100644 (file)
@@ -504,14 +504,9 @@ void IDP_SyncGroupValues(IDProperty *dest, const IDProperty *src)
                                        break;
                                default:
                                {
-                                       IDProperty *tmp = other;
-                                       IDProperty *copy = IDP_CopyProperty(prop);
-
-                                       BLI_insertlinkafter(&dest->data.group, other, copy);
-                                       BLI_remlink(&dest->data.group, tmp);
-
-                                       IDP_FreeProperty(tmp);
-                                       MEM_freeN(tmp);
+                                       BLI_insertlinkreplace(&dest->data.group, other, IDP_CopyProperty(prop));
+                                       IDP_FreeProperty(other);
+                                       MEM_freeN(other);
                                        break;
                                }
                        }
@@ -531,11 +526,9 @@ void IDP_SyncGroupTypes(IDProperty *dst, const IDProperty *src, const bool do_ar
                        if ((prop_dst->type != prop_src->type || prop_dst->subtype != prop_src->subtype) ||
                            (do_arraylen && ELEM(prop_dst->type, IDP_ARRAY, IDP_IDPARRAY) && (prop_src->len != prop_dst->len)))
                        {
-                               IDP_FreeFromGroup(dst, prop_dst);
-                               prop_dst = IDP_CopyProperty(prop_src);
-
-                               dst->len++;
-                               BLI_insertlinkbefore(&dst->data.group, prop_dst_next, prop_dst);
+                               BLI_insertlinkreplace(&dst->data.group, prop_dst, IDP_CopyProperty(prop_src));
+                               IDP_FreeProperty(prop_dst);
+                               MEM_freeN(prop_dst);
                        }
                        else if (prop_dst->type == IDP_GROUP) {
                                IDP_SyncGroupTypes(prop_dst, prop_src, do_arraylen);
@@ -560,11 +553,7 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, const IDProperty *src)
        for (prop = src->data.group.first; prop; prop = prop->next) {
                for (loop = dest->data.group.first; loop; loop = loop->next) {
                        if (STREQ(loop->name, prop->name)) {
-                               IDProperty *copy = IDP_CopyProperty(prop);
-
-                               BLI_insertlinkafter(&dest->data.group, loop, copy);
-
-                               BLI_remlink(&dest->data.group, loop);
+                               BLI_insertlinkreplace(&dest->data.group, loop, IDP_CopyProperty(prop));
                                IDP_FreeProperty(loop);
                                MEM_freeN(loop);
                                break;
@@ -591,9 +580,7 @@ void IDP_ReplaceInGroup_ex(IDProperty *group, IDProperty *prop, IDProperty *prop
        BLI_assert(prop_exist == IDP_GetPropertyFromGroup(group, prop->name));
 
        if ((prop_exist = IDP_GetPropertyFromGroup(group, prop->name))) {
-               BLI_insertlinkafter(&group->data.group, prop_exist, prop);
-               
-               BLI_remlink(&group->data.group, prop_exist);
+               BLI_insertlinkreplace(&group->data.group, prop_exist, prop);
                IDP_FreeProperty(prop_exist);
                MEM_freeN(prop_exist);
        }