Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp	(revision 43593)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp	(revision 43594)
@@ -153,4 +153,39 @@
 }
 
+/* static */
+void UIGChooserItemMachine::enumerateMachineItems(const QList<UIGChooserItem*> &il,
+                                                  QList<UIGChooserItemMachine*> &ol,
+                                                  int iEnumerationFlags /* = 0 */)
+{
+    /* Enumerate all the passed items: */
+    foreach (UIGChooserItem *pItem, il)
+    {
+        /* If that is machine-item: */
+        if (pItem->type() == UIGChooserItemType_Machine)
+        {
+            /* Get the iterated machine-item: */
+            UIGChooserItemMachine *pMachineItem = pItem->toMachineItem();
+            /* Skip if this item is already enumerated but we need unique: */
+            if ((iEnumerationFlags & UIGChooserItemMachineEnumerationFlag_Unique) &&
+                contains(ol, pMachineItem))
+                continue;
+            /* Skip if ths item is accessible and we no need it: */
+            if ((iEnumerationFlags & UIGChooserItemMachineEnumerationFlag_Inaccessible) &&
+                pMachineItem->accessible())
+                continue;
+            /* Add it: */
+            ol << pMachineItem;
+        }
+        /* If that is group-item: */
+        else if (pItem->type() == UIGChooserItemType_Group)
+        {
+            /* Enumerate all the machine-items recursively: */
+            enumerateMachineItems(pItem->items(UIGChooserItemType_Machine), ol, iEnumerationFlags);
+            /* Enumerate all the group-items recursively: */
+            enumerateMachineItems(pItem->items(UIGChooserItemType_Group), ol, iEnumerationFlags);
+        }
+    }
+}
+
 QVariant UIGChooserItemMachine::data(int iKey) const
 {
@@ -869,2 +904,12 @@
 }
 
+/* static */
+bool UIGChooserItemMachine::contains(const QList<UIGChooserItemMachine*> &list, UIGChooserItemMachine *pItem)
+{
+    /* Check if passed list contains passed machine-item id: */
+    foreach (UIGChooserItemMachine *pIteratedItem, list)
+        if (pIteratedItem->id() == pItem->id())
+            return true;
+    return false;
+}
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h	(revision 43593)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h	(revision 43594)
@@ -24,8 +24,18 @@
 #include "UIGChooserItem.h"
 
+/* Other VBox includes: */
+#include <iprt/cdefs.h>
+
 /* Forward declarations: */
 class CMachine;
 class UIGraphicsToolBar;
 class UIGraphicsZoomButton;
+
+/* Machine-item enumeration flags: */
+enum UIGChooserItemMachineEnumerationFlag
+{
+    UIGChooserItemMachineEnumerationFlag_Unique       = RT_BIT(0),
+    UIGChooserItemMachineEnumerationFlag_Inaccessible = RT_BIT(1)
+};
 
 /* Graphics machine item
@@ -56,4 +66,9 @@
     /* API: Update stuff: */
     void updateToolTip();
+
+    /* API: Machine-item enumeration stuff: */
+    static void enumerateMachineItems(const QList<UIGChooserItem*> &il,
+                                      QList<UIGChooserItemMachine*> &ol,
+                                      int iEnumerationFlags = 0);
 
 private:
@@ -139,4 +154,8 @@
     void prepare();
 
+    /* Helper: Machine-item enumeration stuff: */
+    static bool contains(const QList<UIGChooserItemMachine*> &list,
+                         UIGChooserItemMachine *pItem);
+
     /* Variables: */
     UIGraphicsToolBar *m_pToolBar;
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp	(revision 43593)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp	(revision 43594)
@@ -210,8 +210,14 @@
 QList<UIVMItem*> UIGChooserModel::currentMachineItems() const
 {
-    /* Populate list of selected machine-items: */
-    QList<UIVMItem*> currentMachineItemList;
-    enumerateCurrentItems(currentItems(), currentMachineItemList);
-    return currentMachineItemList;
+    /* Gather list of current unique machine-items: */
+    QList<UIGChooserItemMachine*> currentMachineItemList;
+    UIGChooserItemMachine::enumerateMachineItems(currentItems(), currentMachineItemList,
+                                                 UIGChooserItemMachineEnumerationFlag_Unique);
+
+    /* Reintegrate machine-items into valid format: */
+    QList<UIVMItem*> currentMachineList;
+    foreach (UIGChooserItemMachine *pItem, currentMachineItemList)
+        currentMachineList << pItem;
+    return currentMachineList;
 }
 
@@ -914,27 +920,28 @@
         return;
 
-    /* Gather list of chosen inaccessible VMs: */
-    QList<UIGChooserItem*> inaccessibleItems;
-    enumerateInaccessibleItems(currentItems(), inaccessibleItems);
-
-    /* For each inaccessible item: */
+    /* Gather list of current unique inaccessible machine-items: */
+    QList<UIGChooserItemMachine*> inaccessibleMachineItemList;
+    UIGChooserItemMachine::enumerateMachineItems(currentItems(), inaccessibleMachineItemList,
+                                                 UIGChooserItemMachineEnumerationFlag_Unique | UIGChooserItemMachineEnumerationFlag_Inaccessible);
+
+    /* For each machine-item: */
     UIGChooserItem *pSelectedItem = 0;
-    foreach (UIGChooserItem *pItem, inaccessibleItems)
-        if (UIGChooserItemMachine *pMachineItem = pItem->toMachineItem())
+    foreach (UIGChooserItemMachine *pItem, inaccessibleMachineItemList)
+    {
+        /* Recache: */
+        pItem->recache();
+        /* Become accessible? */
+        if (pItem->accessible())
         {
-            /* Recache: */
-            pMachineItem->recache();
-            /* Become accessible? */
-            if (pMachineItem->accessible())
-            {
-                /* Machine name: */
-                QString strMachineName = pMachineItem->name();
-                /* We should reload this machine: */
-                sltReloadMachine(pMachineItem->id());
-                /* Select first of reloaded items: */
-                if (!pSelectedItem)
-                    pSelectedItem = findMachineItem(strMachineName, mainRoot());
-            }
+            /* Machine name: */
+            QString strMachineName = pItem->name();
+            /* We should reload this machine: */
+            sltReloadMachine(pItem->id());
+            /* Select first of reloaded items: */
+            if (!pSelectedItem)
+                pSelectedItem = findMachineItem(strMachineName, mainRoot());
         }
+    }
+
     /* Some item to be selected? */
     if (pSelectedItem)
@@ -952,7 +959,9 @@
 
     /* Enumerate all the selected machine-items: */
-    QList<UIGChooserItem*> selectedMachineItemList = gatherMachineItems(currentItems());
+    QList<UIGChooserItemMachine*> selectedMachineItemList;
+    UIGChooserItemMachine::enumerateMachineItems(currentItems(), selectedMachineItemList);
     /* Enumerate all the existing machine-items: */
-    QList<UIGChooserItem*> existingMachineItemList = gatherMachineItems(mainRoot()->items());
+    QList<UIGChooserItemMachine*> existingMachineItemList;
+    UIGChooserItemMachine::enumerateMachineItems(mainRoot()->items(), existingMachineItemList);
 
     /* Prepare maps: */
@@ -1377,36 +1386,4 @@
 }
 
-void UIGChooserModel::enumerateCurrentItems(const QList<UIGChooserItem*> &il, QList<UIVMItem*> &ol) const
-{
-    /* Enumerate all the passed items: */
-    foreach (UIGChooserItem *pItem, il)
-    {
-        /* If item is machine, add if missed: */
-        if (pItem->type() == UIGChooserItemType_Machine)
-        {
-            if (UIGChooserItemMachine *pMachineItem = pItem->toMachineItem())
-                if (!contains(ol, pMachineItem))
-                    ol << pMachineItem;
-        }
-        /* If item is group: */
-        else if (pItem->type() == UIGChooserItemType_Group)
-        {
-            /* Enumerate all the machine items recursively: */
-            enumerateCurrentItems(pItem->items(UIGChooserItemType_Machine), ol);
-            /* Enumerate all the group items recursively: */
-            enumerateCurrentItems(pItem->items(UIGChooserItemType_Group), ol);
-        }
-    }
-}
-
-bool UIGChooserModel::contains(const QList<UIVMItem*> &list, UIVMItem *pItem) const
-{
-    /* Check if passed list contains passed item: */
-    foreach (UIVMItem *pIteratedItem, list)
-        if (pIteratedItem->id() == pItem->id())
-            return true;
-    return false;
-}
-
 void UIGChooserModel::clearRealFocus()
 {
@@ -1495,50 +1472,4 @@
     /* Nothing found? */
     return 0;
-}
-
-QList<UIGChooserItem*> UIGChooserModel::gatherMachineItems(const QList<UIGChooserItem*> &selectedItems) const
-{
-    QList<UIGChooserItem*> machineItems;
-    foreach (UIGChooserItem *pItem, selectedItems)
-    {
-        if (pItem->type() == UIGChooserItemType_Machine)
-            machineItems << pItem;
-        if (pItem->type() == UIGChooserItemType_Group)
-            machineItems << gatherMachineItems(pItem->items());
-    }
-    return machineItems;
-}
-
-void UIGChooserModel::enumerateInaccessibleItems(const QList<UIGChooserItem*> &il, QList<UIGChooserItem*> &ol) const
-{
-    /* Enumerate all the passed items: */
-    foreach (UIGChooserItem *pItem, il)
-    {
-        /* If item is inaccessible machine: */
-        if (pItem->type() == UIGChooserItemType_Machine)
-        {
-            if (UIGChooserItemMachine *pMachineItem = pItem->toMachineItem())
-                if (!pMachineItem->accessible() && !contains(ol, pItem))
-                    ol << pMachineItem;
-        }
-        /* If item is group: */
-        else if (pItem->type() == UIGChooserItemType_Group)
-        {
-            /* Enumerate all the machine items recursively: */
-            enumerateInaccessibleItems(pItem->items(UIGChooserItemType_Machine), ol);
-            /* Enumerate all the group items recursively: */
-            enumerateInaccessibleItems(pItem->items(UIGChooserItemType_Group), ol);
-        }
-    }
-}
-
-bool UIGChooserModel::contains(const QList<UIGChooserItem*> &il, UIGChooserItem *pLookupItem) const
-{
-    /* We assume passed list contains only machine items: */
-    foreach (UIGChooserItem *pItem, il)
-        if (UIGChooserItemMachine *pMachineItem = pItem->toMachineItem())
-            if (pMachineItem->id() == pLookupItem->toMachineItem()->id())
-                return true;
-    return false;
 }
 
@@ -1598,5 +1529,5 @@
 }
 
-void UIGChooserModel::removeMachineItems(const QStringList &names, QList<UIGChooserItem*> &selectedItems)
+void UIGChooserModel::removeMachineItems(const QStringList &names, QList<UIGChooserItemMachine*> &items)
 {
     /* Show machine-items remove dialog: */
@@ -1606,5 +1537,5 @@
 
     /* Remove all the required items: */
-    foreach (UIGChooserItem *pItem, selectedItems)
+    foreach (UIGChooserItem *pItem, items)
         if (names.contains(pItem->name()))
             delete pItem;
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h	(revision 43593)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h	(revision 43594)
@@ -240,6 +240,4 @@
     /* Helpers: Current-item stuff: */
     UIGChooserItemMachine* firstMachineItem(const QList<UIGChooserItem*> &list) const;
-    void enumerateCurrentItems(const QList<UIGChooserItem*> &il, QList<UIVMItem*> &ol) const;
-    bool contains(const QList<UIVMItem*> &list, UIVMItem *pItem) const;
 
     /* Helper: Focus-item stuff: */
@@ -255,11 +253,8 @@
     /* Helpers: Machine-item stuff: */
     UIGChooserItem* findMachineItem(const QString &strName, UIGChooserItem *pParent);
-    QList<UIGChooserItem*> gatherMachineItems(const QList<UIGChooserItem*> &selectedItems) const;
-    void enumerateInaccessibleItems(const QList<UIGChooserItem*> &il, QList<UIGChooserItem*> &ol) const;
-    bool contains(const QList<UIGChooserItem*> &il, UIGChooserItem *pLookupItem) const;
     void sortItems(UIGChooserItem *pParent, bool fRecursively = false);
     void updateMachineItems(const QString &strId, UIGChooserItem *pParent);
     void removeMachineItems(const QString &strId, UIGChooserItem *pParent);
-    void removeMachineItems(const QStringList &names, QList<UIGChooserItem*> &selectedItems);
+    void removeMachineItems(const QStringList &names, QList<UIGChooserItemMachine*> &selectedItems);
     void unregisterMachines(const QStringList &ids);
 
