From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxGWM-0004tr-0S for qemu-devel@nongnu.org; Mon, 21 Jan 2013 07:30:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TxGWK-0006cz-Mu for qemu-devel@nongnu.org; Mon, 21 Jan 2013 07:30:37 -0500 Received: from mail-ea0-f178.google.com ([209.85.215.178]:37723) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxGWK-0006cq-GA for qemu-devel@nongnu.org; Mon, 21 Jan 2013 07:30:36 -0500 Received: by mail-ea0-f178.google.com with SMTP id a14so2487741eaa.23 for ; Mon, 21 Jan 2013 04:30:35 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 21 Jan 2013 13:30:13 +0100 Message-Id: <1358771422-14282-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1358771422-14282-1-git-send-email-pbonzini@redhat.com> References: <1358771422-14282-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v2 03/12] 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 03e6f24..1a123da 100644 --- a/qom/object.c +++ b/qom/object.c @@ -361,12 +361,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.1