platform: fix nmp_object_copy(id_only) for object that don't implement cmd_plobj_id_copy()

The if-else-if was wrong. It meant that if an object did not implement
cmd_plobj_id_copy(), nothign was copied (for id-only).

I think this code path was not actually hit, because we never clone
an object only by ID.

Fixes: c91a4617a1 ('nmp-object: allow missing implementations for certain virtual functions')
This commit is contained in:
Thomas Haller 2022-11-04 12:45:37 +01:00
parent a275285537
commit ee34eeafb9
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -1317,10 +1317,9 @@ nmp_object_copy(NMPObject *dst, const NMPObject *src, gboolean id_only)
g_return_if_fail(klass == NMP_OBJECT_GET_CLASS(src));
if (id_only) {
if (klass->cmd_plobj_id_copy)
klass->cmd_plobj_id_copy(&dst->object, &src->object);
} else if (klass->cmd_obj_copy)
if (id_only && klass->cmd_plobj_id_copy)
klass->cmd_plobj_id_copy(&dst->object, &src->object);
else if (klass->cmd_obj_copy)
klass->cmd_obj_copy(dst, src);
else
memcpy(&dst->object, &src->object, klass->sizeof_data);