From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgLpx-0008MR-C4 for qemu-devel@nongnu.org; Wed, 05 Dec 2012 15:44:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TgLpv-0001Bb-Fb for qemu-devel@nongnu.org; Wed, 05 Dec 2012 15:44:57 -0500 Received: from mail-ee0-f45.google.com ([74.125.83.45]:57746) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgLpv-0001AN-A0 for qemu-devel@nongnu.org; Wed, 05 Dec 2012 15:44:55 -0500 Received: by mail-ee0-f45.google.com with SMTP id d49so3380495eek.4 for ; Wed, 05 Dec 2012 12:44:54 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 5 Dec 2012 21:44:34 +0100 Message-Id: <1354740282-20679-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1354740282-20679-1-git-send-email-pbonzini@redhat.com> References: <1354740282-20679-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 03/11] qom: preserve object while unparenting it List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, afaerber@suse.de Avoid that the object disappears after it's deleted from the QOM composition tree, in case that was the only reference to it. Signed-off-by: Paolo Bonzini --- qom/object.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qom/object.c b/qom/object.c index 0739aa2..ecdf164 100644 --- a/qom/object.c +++ b/qom/object.c @@ -360,12 +360,14 @@ static void object_property_del_child(Object *obj, Object *child, Error **errp) void object_unparent(Object *obj) { + object_ref(obj); if (obj->parent) { object_property_del_child(obj->parent, obj, NULL); } if (obj->class->unparent) { (obj->class->unparent)(obj); } + object_unref(obj); } static void object_deinit(Object *obj, TypeImpl *type) -- 1.8.0.1