Index: /trunk/src/VBox/Main/ConsoleImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/ConsoleImpl.cpp	(revision 33707)
+++ /trunk/src/VBox/Main/ConsoleImpl.cpp	(revision 33708)
@@ -507,10 +507,4 @@
 
     LogFlowThisFunc(("initFailed()=%d\n", autoUninitSpan.initFailed()));
-
-    /*
-     * Uninit all children that use addDependentChild()/removeDependentChild()
-     * in their init()/uninit() methods.
-     */
-    uninitDependentChildren();
 
     /* power down the VM if necessary */
Index: /trunk/src/VBox/Main/DisplayImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/DisplayImpl.cpp	(revision 33707)
+++ /trunk/src/VBox/Main/DisplayImpl.cpp	(revision 33708)
@@ -2789,5 +2789,4 @@
 
     /// @todo (dmik) can we AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); here?
-    //  do it when we switch this class to VirtualBoxBase_NEXT.
     //  This will require general code review and may add some details.
     //  In particular, we may want to check whether EMT is really waiting for
Index: /trunk/src/VBox/Main/MachineImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MachineImpl.cpp	(revision 33707)
+++ /trunk/src/VBox/Main/MachineImpl.cpp	(revision 33708)
@@ -6579,8 +6579,4 @@
                            || autoCaller.state() == Limited);
 
-    /* uninit all children using addDependentChild()/removeDependentChild()
-     * in their init()/uninit() methods */
-    uninitDependentChildren();
-
     /* tell all our other child objects we've been uninitialized */
 
Index: /trunk/src/VBox/Main/MediumImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MediumImpl.cpp	(revision 33707)
+++ /trunk/src/VBox/Main/MediumImpl.cpp	(revision 33708)
@@ -1324,7 +1324,6 @@
     if (m->state == MediumState_Deleting)
     {
-        /* we are being reinitialized after we've been deleted by merge.
-         * Reparenting has already been done so don't touch it here (we are
-         * now orphans and removeDependentChild() will assert) */
+        /* This medium has been already deleted (directly or as part of a
+         * merge).  Reparenting has already been done. */
         Assert(m->pParent.isNull());
     }
Index: /trunk/src/VBox/Main/MouseImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MouseImpl.cpp	(revision 33707)
+++ /trunk/src/VBox/Main/MouseImpl.cpp	(revision 33708)
@@ -577,5 +577,5 @@
 
     rc = reportAbsEvent(mouseXAbs, mouseYAbs, dz, dw, fButtons,
-                        mouseCaps & VMMDEV_MOUSE_GUEST_USES_EVENT);
+                        !!(mouseCaps & VMMDEV_MOUSE_GUEST_USES_EVENT));
 
 #ifndef VBOXBFE_WITHOUT_COM
Index: /trunk/src/VBox/Main/StorageControllerImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/StorageControllerImpl.cpp	(revision 33707)
+++ /trunk/src/VBox/Main/StorageControllerImpl.cpp	(revision 33708)
@@ -150,8 +150,4 @@
 
     /* m->pPeer is left null */
-
-    /* register with parent early, since uninit() will unconditionally
-     * unregister on failure */
-    m->pParent->addDependentChild(this);
 
     m->bd.allocate();
@@ -227,8 +223,4 @@
     m = new Data(aParent);
 
-    /* register with parent early, since uninit() will unconditionally
-     * unregister on failure */
-    m->pParent->addDependentChild(this);
-
     /* sanity */
     AutoCaller thatCaller(aThat);
@@ -274,6 +266,4 @@
     /* m->pPeer is left null */
 
-    m->pParent->addDependentChild(this);
-
     AutoCaller thatCaller(aThat);
     AssertComRCReturnRC(thatCaller.rc());
@@ -303,6 +293,4 @@
 
     m->bd.free();
-
-    m->pParent->removeDependentChild(this);
 
     unconst(m->pPeer) = NULL;
Index: /trunk/src/VBox/Main/USBControllerImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/USBControllerImpl.cpp	(revision 33707)
+++ /trunk/src/VBox/Main/USBControllerImpl.cpp	(revision 33708)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -507,5 +507,4 @@
     ComObjPtr<USBDeviceFilter> filter = static_cast<USBDeviceFilter*>(aFilter);
     // @todo r=dj make sure the input object is actually from us
-//     ComObjPtr<USBDeviceFilter> filter = getDependentChild(aFilter);
 //     if (!filter)
 //         return setError (E_INVALIDARG,
Index: /trunk/src/VBox/Main/VirtualBoxBase.cpp
===================================================================
--- /trunk/src/VBox/Main/VirtualBoxBase.cpp	(revision 33707)
+++ /trunk/src/VBox/Main/VirtualBoxBase.cpp	(revision 33708)
@@ -696,7 +696,5 @@
             /* otherwise, wait until another thread finishes uninitialization.
              * This is necessary to make sure that when this method returns, the
-             * object is NotReady and therefore can be deleted (for example).
-             * In particular, this is used by
-             * VirtualBoxBaseWithTypedChildrenNEXT::uninitDependentChildren(). */
+             * object is NotReady and therefore can be deleted (for example). */
 
             /* lazy semaphore creation */
@@ -763,156 +761,4 @@
 ////////////////////////////////////////////////////////////////////////////////
 //
-// VirtualBoxBaseWithChildrenNEXT methods
-//
-////////////////////////////////////////////////////////////////////////////////
-
-/**
- * Uninitializes all dependent children registered on this object with
- * #addDependentChild().
- *
- * Must be called from within the AutoUninitSpan (i.e.
- * typically from this object's uninit() method) to uninitialize children
- * before this object goes out of service and becomes unusable.
- *
- * Note that this method will call uninit() methods of child objects. If
- * these methods need to call the parent object during uninitialization,
- * #uninitDependentChildren() must be called before the relevant part of the
- * parent is uninitialized: usually at the beginning of the parent
- * uninitialization sequence.
- *
- * Keep in mind that the uninitialized child objects may be no longer available
- * (i.e. may be deleted) after this method returns.
- *
- * @note Locks #childrenLock() for writing.
- *
- * @note May lock something else through the called children.
- */
-void VirtualBoxBaseWithChildrenNEXT::uninitDependentChildren()
-{
-    AutoCaller autoCaller(this);
-
-    /* sanity */
-    AssertReturnVoid (autoCaller.state() == InUninit ||
-                      autoCaller.state() == InInit);
-
-    AutoWriteLock chLock(childrenLock() COMMA_LOCKVAL_SRC_POS);
-
-    size_t count = mDependentChildren.size();
-
-    while (count != 0)
-    {
-        /* strongly reference the weak child from the map to make sure it won't
-         * be deleted while we've released the lock */
-        DependentChildren::iterator it = mDependentChildren.begin();
-        ComPtr<IUnknown> unk = it->first;
-        Assert(!unk.isNull());
-
-        VirtualBoxBase *child = it->second;
-
-        /* release the lock to let children stuck in removeDependentChild() go
-         * on (otherwise we'll deadlock in uninit() */
-        chLock.leave();
-
-        /* Note that if child->uninit() happens to be called on another
-         * thread right before us and is not yet finished, the second
-         * uninit() call will wait until the first one has done so
-         * (thanks to AutoUninitSpan). */
-        Assert(child);
-        if (child)
-            child->uninit();
-
-        chLock.enter();
-
-        /* uninit() is guaranteed to be done here so the child must be already
-         * deleted from the list by removeDependentChild() called from there.
-         * Do some checks to avoid endless loops when the user is forgetful */
-        -- count;
-        Assert(count == mDependentChildren.size());
-        if (count != mDependentChildren.size())
-            mDependentChildren.erase (it);
-
-        Assert(count == mDependentChildren.size());
-    }
-}
-
-/**
- * Returns a pointer to the dependent child (registered using
- * #addDependentChild()) corresponding to the given interface pointer or NULL if
- * the given pointer is unrelated.
- *
- * The relation is checked by using the given interface pointer as a key in the
- * map of dependent children.
- *
- * Note that ComPtr<IUnknown> is used as an argument instead of IUnknown * in
- * order to guarantee IUnknown identity and disambiguation by doing
- * QueryInterface (IUnknown) rather than a regular C cast.
- *
- * @param aUnk  Pointer to map to the dependent child object.
- * @return      Pointer to the dependent VirtualBoxBase child object.
- *
- * @note Locks #childrenLock() for reading.
- */
-VirtualBoxBase* VirtualBoxBaseWithChildrenNEXT::getDependentChild(const ComPtr<IUnknown> &aUnk)
-{
-    AssertReturn(!aUnk.isNull(), NULL);
-
-    AutoCaller autoCaller(this);
-
-    /* return NULL if uninitDependentChildren() is in action */
-    if (autoCaller.state() == InUninit)
-        return NULL;
-
-    AutoReadLock alock(childrenLock() COMMA_LOCKVAL_SRC_POS);
-
-    DependentChildren::const_iterator it = mDependentChildren.find (aUnk);
-    if (it == mDependentChildren.end())
-        return NULL;
-
-    return (*it).second;
-}
-
-/** Helper for addDependentChild(). */
-void VirtualBoxBaseWithChildrenNEXT::doAddDependentChild(IUnknown *aUnk,
-                                                         VirtualBoxBase *aChild)
-{
-    AssertReturnVoid (aUnk != NULL);
-    AssertReturnVoid (aChild != NULL);
-
-    AutoCaller autoCaller(this);
-
-    /* sanity */
-    AssertReturnVoid (autoCaller.state() == InInit ||
-                      autoCaller.state() == Ready ||
-                      autoCaller.state() == Limited);
-
-    AutoWriteLock alock(childrenLock() COMMA_LOCKVAL_SRC_POS);
-
-    std::pair <DependentChildren::iterator, bool> result =
-        mDependentChildren.insert (DependentChildren::value_type (aUnk, aChild));
-    AssertMsg (result.second, ("Failed to insert child %p to the map\n", aUnk));
-}
-
-/** Helper for removeDependentChild(). */
-void VirtualBoxBaseWithChildrenNEXT::doRemoveDependentChild (IUnknown *aUnk)
-{
-    AssertReturnVoid (aUnk);
-
-    AutoCaller autoCaller(this);
-
-    /* sanity */
-    AssertReturnVoid (autoCaller.state() == InUninit ||
-                      autoCaller.state() == InInit ||
-                      autoCaller.state() == Ready ||
-                      autoCaller.state() == Limited);
-
-    AutoWriteLock alock(childrenLock() COMMA_LOCKVAL_SRC_POS);
-
-    DependentChildren::size_type result = mDependentChildren.erase (aUnk);
-    AssertMsg (result == 1, ("Failed to remove child %p from the map\n", aUnk));
-    NOREF (result);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//
 // MultiResult methods
 //
Index: /trunk/src/VBox/Main/include/ConsoleImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 33707)
+++ /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 33708)
@@ -79,5 +79,5 @@
 /** IConsole implementation class */
 class ATL_NO_VTABLE Console :
-    public VirtualBoxBaseWithChildrenNEXT,
+    public VirtualBoxBase,
     VBOX_SCRIPTABLE_IMPL(IConsole)
 #ifdef RT_OS_WINDOWS
Index: /trunk/src/VBox/Main/include/MachineImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/MachineImpl.h	(revision 33707)
+++ /trunk/src/VBox/Main/include/MachineImpl.h	(revision 33708)
@@ -81,5 +81,5 @@
 
 class ATL_NO_VTABLE Machine :
-    public VirtualBoxBaseWithChildrenNEXT,
+    public VirtualBoxBase,
     VBOX_SCRIPTABLE_IMPL(IMachine)
 {
Index: /trunk/src/VBox/Main/include/SharedFolderImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/SharedFolderImpl.h	(revision 33707)
+++ /trunk/src/VBox/Main/include/SharedFolderImpl.h	(revision 33708)
@@ -25,5 +25,5 @@
 
 class ATL_NO_VTABLE SharedFolder :
-    public VirtualBoxBaseWithChildrenNEXT,
+    public VirtualBoxBase,
     VBOX_SCRIPTABLE_IMPL(ISharedFolder)
 {
Index: /trunk/src/VBox/Main/include/VirtualBoxBase.h
===================================================================
--- /trunk/src/VBox/Main/include/VirtualBoxBase.h	(revision 33707)
+++ /trunk/src/VBox/Main/include/VirtualBoxBase.h	(revision 33708)
@@ -630,9 +630,4 @@
      * last reference to the object is released, before calling the destructor.
      *
-     * This method is also automatically called by the uninit() method of this
-     * object's parent if this object is a dependent child of a class derived
-     * from VirtualBoxBaseWithChildren (see
-     * VirtualBoxBaseWithChildren::addDependentChild).
-     *
      * @note Never call this method the AutoCaller scope or after the
      *       #addCaller() call not paired by #releaseCaller() because it is a
@@ -748,180 +743,4 @@
 ////////////////////////////////////////////////////////////////////////////////
 
-/**
- * Base class to track VirtualBoxBaseNEXT chlidren of the component.
- *
- * This class is a preferable VirtualBoxBase replacement for components that
- * operate with collections of child components. It gives two useful
- * possibilities:
- *
- * <ol><li>
- *      Given an IUnknown instance, it's possible to quickly determine
- *      whether this instance represents a child object that belongs to the
- *      given component, and if so, get a valid VirtualBoxBase pointer to the
- *      child object. The returned pointer can be then safely casted to the
- *      actual class of the child object (to get access to its "internal"
- *      non-interface methods) provided that no other child components implement
- *      the same original COM interface IUnknown is queried from.
- * </li><li>
- *      When the parent object uninitializes itself, it can easily uninitialize
- *      all its VirtualBoxBase derived children (using their
- *      VirtualBoxBase::uninit() implementations). This is done simply by
- *      calling the #uninitDependentChildren() method.
- * </li></ol>
- *
- * In order to let the above work, the following must be done:
- * <ol><li>
- *      When a child object is initialized, it calls #addDependentChild() of
- *      its parent to register itself within the list of dependent children.
- * </li><li>
- *      When the child object it is uninitialized, it calls
- *      #removeDependentChild() to unregister itself.
- * </li></ol>
- *
- * Note that if the parent object does not call #uninitDependentChildren() when
- * it gets uninitialized, it must call uninit() methods of individual children
- * manually to disconnect them; a failure to do so will cause crashes in these
- * methods when children get destroyed. The same applies to children not calling
- * #removeDependentChild() when getting destroyed.
- *
- * Note that children added by #addDependentChild() are <b>weakly</b> referenced
- * (i.e. AddRef() is not called), so when a child object is deleted externally
- * (because it's reference count goes to zero), it will automatically remove
- * itself from the map of dependent children provided that it follows the rules
- * described here.
- *
- * Access to the child list is serialized using the #childrenLock() lock handle
- * (which defaults to the general object lock handle (see
- * VirtualBoxBase::lockHandle()). This lock is used by all add/remove methods of
- * this class so be aware of the need to preserve the {parent, child} lock order
- * when calling these methods.
- *
- * Read individual method descriptions to get further information.
- *
- * @todo This is a VirtualBoxBaseWithChildren equivalent that uses the
- *       VirtualBoxBaseNEXT implementation. Will completely supersede
- *       VirtualBoxBaseWithChildren after the old VirtualBoxBase implementation
- *       has gone.
- */
-class VirtualBoxBaseWithChildrenNEXT : public VirtualBoxBase
-{
-public:
-
-    VirtualBoxBaseWithChildrenNEXT()
-    {}
-
-    virtual ~VirtualBoxBaseWithChildrenNEXT()
-    {}
-
-    /**
-     * Lock handle to use when adding/removing child objects from the list of
-     * children. It is guaranteed that no any other lock is requested in methods
-     * of this class while holding this lock.
-     *
-     * @warning By default, this simply returns the general object's lock handle
-     *          (see VirtualBoxBase::lockHandle()) which is sufficient for most
-     *          cases.
-     */
-    virtual RWLockHandle *childrenLock() { return lockHandle(); }
-
-    /**
-     * Adds the given child to the list of dependent children.
-     *
-     * Usually gets called from the child's init() method.
-     *
-     * @note @a aChild (unless it is in InInit state) must be protected by
-     *       VirtualBoxBase::AutoCaller to make sure it is not uninitialized on
-     *       another thread during this method's call.
-     *
-     * @note When #childrenLock() is not overloaded (returns the general object
-     *       lock) and this method is called from under the child's read or
-     *       write lock, make sure the {parent, child} locking order is
-     *       preserved by locking the callee (this object) for writing before
-     *       the child's lock.
-     *
-     * @param aChild    Child object to add (must inherit VirtualBoxBase AND
-     *                  implement some interface).
-     *
-     * @note Locks #childrenLock() for writing.
-     */
-    template<class C>
-    void addDependentChild(C *aChild)
-    {
-        AssertReturnVoid(aChild != NULL);
-        doAddDependentChild(ComPtr<IUnknown>(aChild), aChild);
-    }
-
-    /**
-     * Equivalent to template <class C> void addDependentChild (C *aChild)
-     * but takes a ComObjPtr<C> argument.
-     */
-    template<class C>
-    void addDependentChild(const ComObjPtr<C> &aChild)
-    {
-        AssertReturnVoid(!aChild.isNull());
-        doAddDependentChild(ComPtr<IUnknown>(static_cast<C *>(aChild)), aChild);
-    }
-
-    /**
-     * Removes the given child from the list of dependent children.
-     *
-     * Usually gets called from the child's uninit() method.
-     *
-     * Keep in mind that the called (parent) object may be no longer available
-     * (i.e. may be deleted deleted) after this method returns, so you must not
-     * call any other parent's methods after that!
-     *
-     * @note Locks #childrenLock() for writing.
-     *
-     * @note @a aChild (unless it is in InUninit state) must be protected by
-     *       VirtualBoxBase::AutoCaller to make sure it is not uninitialized on
-     *       another thread during this method's call.
-     *
-     * @note When #childrenLock() is not overloaded (returns the general object
-     *       lock) and this method is called from under the child's read or
-     *       write lock, make sure the {parent, child} locking order is
-     *       preserved by locking the callee (this object) for writing before
-     *       the child's lock. This is irrelevant when the method is called from
-     *       under this object's VirtualBoxBaseProto::AutoUninitSpan (i.e. in
-     *       InUninit state) since in this case no locking is done.
-     *
-     * @param aChild    Child object to remove.
-     *
-     * @note Locks #childrenLock() for writing.
-     */
-    template<class C>
-    void removeDependentChild(C *aChild)
-    {
-        AssertReturnVoid(aChild != NULL);
-        doRemoveDependentChild(ComPtr<IUnknown>(aChild));
-    }
-
-    /**
-     * Equivalent to template <class C> void removeDependentChild (C *aChild)
-     * but takes a ComObjPtr<C> argument.
-     */
-    template<class C>
-    void removeDependentChild(const ComObjPtr<C> &aChild)
-    {
-        AssertReturnVoid(!aChild.isNull());
-        doRemoveDependentChild(ComPtr<IUnknown>(static_cast<C *>(aChild)));
-    }
-
-protected:
-
-    void uninitDependentChildren();
-
-    VirtualBoxBase *getDependentChild(const ComPtr<IUnknown> &aUnk);
-
-private:
-    void doAddDependentChild(IUnknown *aUnk, VirtualBoxBase *aChild);
-    void doRemoveDependentChild(IUnknown *aUnk);
-
-    typedef std::map<IUnknown*, VirtualBoxBase*> DependentChildren;
-    DependentChildren mDependentChildren;
-};
-
-////////////////////////////////////////////////////////////////////////////////
-
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -1022,5 +841,4 @@
 };
 
-/// @todo (dmik) remove after we switch to VirtualBoxBaseNEXT completely
 /**
  *  Simple template that enhances Shareable<> and supports data
