Index: trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSelector.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSelector.cpp	(revision 101391)
+++ trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSelector.cpp	(revision 101392)
@@ -321,18 +321,24 @@
 {
     QWidget *pResult = 0;
-    if (pPage != 0)
-    {
+    if (pPage)
+    {
+        /* Adjust page a bit: */
+        pPage->setContentsMargins(0, 0, 0, 0);
+        if (pPage->layout())
+            pPage->layout()->setContentsMargins(0, 0, 0, 0);
+        pResult = pPage;
+
+        /* Add selector-item object: */
         const QIcon icon = UIIconPool::iconSet(strMediumIcon);
-
         UISelectorItem *pItem = new UISelectorItem(icon, iID, strLink, pPage, iParentID);
-        m_list.append(pItem);
-
-        QTreeWidgetItem *pTwItem = new QITreeWidgetItem(m_pTreeWidget, QStringList() << QString("")
-                                                                                     << idToString(iID)
-                                                                                     << strLink);
-        pTwItem->setIcon(TreeWidgetSection_Category, pItem->icon());
-        pPage->setContentsMargins(0, 0, 0, 0);
-        pPage->layout()->setContentsMargins(0, 0, 0, 0);
-        pResult = pPage;
+        if (pItem)
+            m_list.append(pItem);
+
+        /* Add tree-widget item: */
+        QITreeWidgetItem *pTwItem = new QITreeWidgetItem(m_pTreeWidget, QStringList() << QString("")
+                                                                                      << idToString(iID)
+                                                                                      << strLink);
+        if (pTwItem)
+            pTwItem->setIcon(TreeWidgetSection_Category, pItem->icon());
     }
     return pResult;
@@ -341,5 +347,8 @@
 void UISettingsSelectorTreeWidget::setItemText(int iID, const QString &strText)
 {
+    /* Call to base-class: */
     UISettingsSelector::setItemText(iID, strText);
+
+    /* Look for the tree-widget item to assign the text: */
     QTreeWidgetItem *pItem = findItem(m_pTreeWidget, idToString(iID), TreeWidgetSection_Id);
     if (pItem)
@@ -380,11 +389,10 @@
 {
     /* Get recommended size hint: */
-    const QStyle *pStyle = QApplication::style();
-    const int iIconMetric = pStyle->pixelMetric(QStyle::PM_SmallIconSize);
-    int iItemWidth = static_cast<QAbstractItemView*>(m_pTreeWidget)->sizeHintForColumn(TreeWidgetSection_Category);
-    int iItemHeight = qMax((int)(iIconMetric * 1.5) /* icon height */,
-                           m_pTreeWidget->fontMetrics().height() /* text height */);
-    /* Add some margin to every item in the tree: */
-    iItemHeight += 4 /* margin itself */ * 2 /* margin count */;
+    const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
+    const int iItemWidth = static_cast<QAbstractItemView*>(m_pTreeWidget)->sizeHintForColumn(TreeWidgetSection_Category);
+    const int iItemHeight = qMax((int)(iIconMetric * 1.5) /* icon height */,
+                                 m_pTreeWidget->fontMetrics().height() /* text height */)
+                          + 4 /* margin itself */ * 2 /* margin count */;
+
     /* Set final size hint for items: */
     m_pTreeWidget->setSizeHintForItems(QSize(iItemWidth , iItemHeight));
@@ -392,6 +400,6 @@
     /* Adjust selector width/height: */
     m_pTreeWidget->setFixedWidth(iItemWidth + 2 * m_pTreeWidget->frameWidth());
-    m_pTreeWidget->setMinimumHeight(m_pTreeWidget->topLevelItemCount() * iItemHeight +
-                                    1 /* margin itself */ * 2 /* margin count */);
+    m_pTreeWidget->setMinimumHeight(  m_pTreeWidget->topLevelItemCount() * iItemHeight
+                                    + 1 /* margin itself */ * 2 /* margin count */);
 
     /* Sort selector by the id column: */
@@ -402,6 +410,5 @@
 }
 
-void UISettingsSelectorTreeWidget::sltSettingsGroupChanged(QTreeWidgetItem *pItem,
-                                                         QTreeWidgetItem * /* pPrevItem */)
+void UISettingsSelectorTreeWidget::sltSettingsGroupChanged(QTreeWidgetItem *pItem, QTreeWidgetItem * /* pPrevItem */)
 {
     if (pItem)
@@ -443,19 +450,12 @@
 QString UISettingsSelectorTreeWidget::pagePath(const QString &strMatch) const
 {
-    const QTreeWidgetItem *pTreeItem =
-        findItem(m_pTreeWidget,
-                 strMatch,
-                 TreeWidgetSection_Id);
+    const QTreeWidgetItem *pTreeItem = findItem(m_pTreeWidget, strMatch, TreeWidgetSection_Id);
     return path(pTreeItem);
 }
 
-QTreeWidgetItem *UISettingsSelectorTreeWidget::findItem(QTreeWidget *pView,
-                                                        const QString &strMatch,
-                                                        int iColumn) const
-{
-    QList<QTreeWidgetItem*> list =
-        pView->findItems(strMatch, Qt::MatchExactly, iColumn);
-
-    return list.count() ? list[0] : 0;
+QTreeWidgetItem *UISettingsSelectorTreeWidget::findItem(QTreeWidget *pView, const QString &strMatch, int iColumn) const
+{
+    const QList<QTreeWidgetItem*> list = pView->findItems(strMatch, Qt::MatchExactly, iColumn);
+    return list.count() ? list.first() : 0;
 }
 
