]> xenbits.xensource.com Git - qemu-upstream-4.4-testing.git/commitdiff
qom: call class destructor before unparent
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 18 Mar 2013 19:01:37 +0000 (21:01 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 26 Mar 2013 19:00:45 +0000 (21:00 +0200)
It seems more logical to have destruction flow start with the subclass
and move up to the base class.  This ensures object has a valid
canonical path when destructor is called.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
qom/object.c

index 3d638ff273e80464ab7d06b890d92dee7a91a3c8..a0e3cbe5596cf8b487643967f83b4e4e864e60b7 100644 (file)
@@ -363,12 +363,12 @@ 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);
     }
+    if (obj->parent) {
+        object_property_del_child(obj->parent, obj, NULL);
+    }
     object_unref(obj);
 }