Index: /trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStorageSettingsEditor.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStorageSettingsEditor.cpp	(revision 102934)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStorageSettingsEditor.cpp	(revision 102935)
@@ -3043,99 +3043,99 @@
 {
     /* Check whether update is required: */
-    if (m_enmConfigurationAccessLevel != enmConfigurationAccessLevel)
-    {
-        /* Update value and let model know: */
-        m_enmConfigurationAccessLevel = enmConfigurationAccessLevel;
-        if (m_pModelStorage)
-            m_pModelStorage->setConfigurationAccessLevel(enmConfigurationAccessLevel);
-
-        /* Check actual level: */
-        const bool fMachineOffline = m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Full;
-        const bool fMachinePoweredOff = m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Partial_PoweredOff;
-        const bool fMachineSaved = m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Partial_Saved;
-        const bool fMachineOnline = m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Partial_Running;
-        const bool fMachineInValidMode = fMachineOffline || fMachinePoweredOff || fMachineSaved || fMachineOnline;
-
-        /* Declare required variables: */
-        const QModelIndex index = m_pTreeViewStorage->currentIndex();
-        const KDeviceType enmDeviceType = m_pModelStorage->data(index, StorageModel::R_AttDevice).value<KDeviceType>();
-
-        /* Polish left pane availability: */
-        m_pLabelSeparatorLeftPane->setEnabled(fMachineInValidMode);
-        m_pTreeViewStorage->setEnabled(fMachineInValidMode);
-
-        /* Polish empty information pane availability: */
-        m_pLabelSeparatorEmpty->setEnabled(fMachineInValidMode);
-        m_pLabelInfo->setEnabled(fMachineInValidMode);
-
-        /* Polish controllers pane availability: */
-        m_pLabelSeparatorParameters->setEnabled(fMachineInValidMode);
-        m_pLabelName->setEnabled(fMachineOffline);
-        m_pEditorName->setEnabled(fMachineOffline);
-        m_pLabelType->setEnabled(fMachineOffline);
-        m_pComboType->setEnabled(fMachineOffline);
-        m_pLabelPortCount->setEnabled(fMachineOffline);
-        m_pSpinboxPortCount->setEnabled(fMachineOffline);
-        m_pCheckBoxIoCache->setEnabled(fMachineOffline);
-
-        /* Polish attachments pane availability: */
-        m_pLabelSeparatorAttributes->setEnabled(fMachineInValidMode);
-        m_pLabelMedium->setEnabled(fMachineOffline || (fMachineOnline && enmDeviceType != KDeviceType_HardDisk));
-        m_pComboSlot->setEnabled(fMachineOffline);
-        m_pToolButtonOpen->setEnabled(fMachineOffline || (fMachineOnline && enmDeviceType != KDeviceType_HardDisk));
-        m_pCheckBoxPassthrough->setEnabled(fMachineOffline);
-        m_pCheckBoxTempEject->setEnabled(fMachineInValidMode);
-        m_pCheckBoxNonRotational->setEnabled(fMachineOffline);
-        m_pCheckBoxHotPluggable->setEnabled(fMachineOffline);
-        m_pLabelSeparatorInformation->setEnabled(fMachineInValidMode);
-        m_pLabelHDFormat->setEnabled(fMachineInValidMode);
-        m_pFieldHDFormat->setEnabled(fMachineInValidMode);
-        m_pLabelCDFDType->setEnabled(fMachineInValidMode);
-        m_pFieldCDFDType->setEnabled(fMachineInValidMode);
-        m_pLabelHDVirtualSize->setEnabled(fMachineInValidMode);
-        m_pFieldHDVirtualSize->setEnabled(fMachineInValidMode);
-        m_pLabelHDActualSize->setEnabled(fMachineInValidMode);
-        m_pFieldHDActualSize->setEnabled(fMachineInValidMode);
-        m_pLabelCDFDSize->setEnabled(fMachineInValidMode);
-        m_pFieldCDFDSize->setEnabled(fMachineInValidMode);
-        m_pLabelHDDetails->setEnabled(fMachineInValidMode);
-        m_pFieldHDDetails->setEnabled(fMachineInValidMode);
-        m_pLabelLocation->setEnabled(fMachineInValidMode);
-        m_pFieldLocation->setEnabled(fMachineInValidMode);
-        m_pLabelUsage->setEnabled(fMachineInValidMode);
-        m_pFieldUsage->setEnabled(fMachineInValidMode);
-        m_pLabelEncryption->setEnabled(fMachineInValidMode);
-        m_pFieldEncryption->setEnabled(fMachineInValidMode);
-
-        /* Update remaining stuff: */
-        sltUpdateActionStates();
-        sltGetInformation();
-    }
+    if (m_enmConfigurationAccessLevel == enmConfigurationAccessLevel)
+        return;
+
+    /* Update the value: */
+    m_enmConfigurationAccessLevel = enmConfigurationAccessLevel;
+
+    /* Propagate value to storage model as well: */
+    AssertPtrReturnVoid(m_pModelStorage);
+    m_pModelStorage->setConfigurationAccessLevel(enmConfigurationAccessLevel);
+
+    /* Acquire various options: */
+    const bool fMachineOffline = m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Full;
+    const bool fMachinePoweredOff = m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Partial_PoweredOff;
+    const bool fMachineSaved = m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Partial_Saved;
+    const bool fMachineOnline = m_enmConfigurationAccessLevel == ConfigurationAccessLevel_Partial_Running;
+    const bool fMachineInValidMode = fMachineOffline || fMachinePoweredOff || fMachineSaved || fMachineOnline;
+    const QModelIndex index = m_pTreeViewStorage->currentIndex();
+    const KDeviceType enmDeviceType = m_pModelStorage->data(index, StorageModel::R_AttDevice).value<KDeviceType>();
+
+    /* Polish left pane availability: */
+    m_pLabelSeparatorLeftPane->setEnabled(fMachineInValidMode);
+    m_pTreeViewStorage->setEnabled(fMachineInValidMode);
+
+    /* Polish empty information pane availability: */
+    m_pLabelSeparatorEmpty->setEnabled(fMachineInValidMode);
+    m_pLabelInfo->setEnabled(fMachineInValidMode);
+
+    /* Polish controllers pane availability: */
+    m_pLabelSeparatorParameters->setEnabled(fMachineInValidMode);
+    m_pLabelName->setEnabled(fMachineOffline);
+    m_pEditorName->setEnabled(fMachineOffline);
+    m_pLabelType->setEnabled(fMachineOffline);
+    m_pComboType->setEnabled(fMachineOffline);
+    m_pLabelPortCount->setEnabled(fMachineOffline);
+    m_pSpinboxPortCount->setEnabled(fMachineOffline);
+    m_pCheckBoxIoCache->setEnabled(fMachineOffline);
+
+    /* Polish attachments pane availability: */
+    m_pLabelSeparatorAttributes->setEnabled(fMachineInValidMode);
+    m_pLabelMedium->setEnabled(fMachineOffline || (fMachineOnline && enmDeviceType != KDeviceType_HardDisk));
+    m_pComboSlot->setEnabled(fMachineOffline);
+    m_pToolButtonOpen->setEnabled(fMachineOffline || (fMachineOnline && enmDeviceType != KDeviceType_HardDisk));
+    m_pCheckBoxPassthrough->setEnabled(fMachineOffline);
+    m_pCheckBoxTempEject->setEnabled(fMachineInValidMode);
+    m_pCheckBoxNonRotational->setEnabled(fMachineOffline);
+    m_pCheckBoxHotPluggable->setEnabled(fMachineOffline);
+    m_pLabelSeparatorInformation->setEnabled(fMachineInValidMode);
+    m_pLabelHDFormat->setEnabled(fMachineInValidMode);
+    m_pFieldHDFormat->setEnabled(fMachineInValidMode);
+    m_pLabelCDFDType->setEnabled(fMachineInValidMode);
+    m_pFieldCDFDType->setEnabled(fMachineInValidMode);
+    m_pLabelHDVirtualSize->setEnabled(fMachineInValidMode);
+    m_pFieldHDVirtualSize->setEnabled(fMachineInValidMode);
+    m_pLabelHDActualSize->setEnabled(fMachineInValidMode);
+    m_pFieldHDActualSize->setEnabled(fMachineInValidMode);
+    m_pLabelCDFDSize->setEnabled(fMachineInValidMode);
+    m_pFieldCDFDSize->setEnabled(fMachineInValidMode);
+    m_pLabelHDDetails->setEnabled(fMachineInValidMode);
+    m_pFieldHDDetails->setEnabled(fMachineInValidMode);
+    m_pLabelLocation->setEnabled(fMachineInValidMode);
+    m_pFieldLocation->setEnabled(fMachineInValidMode);
+    m_pLabelUsage->setEnabled(fMachineInValidMode);
+    m_pFieldUsage->setEnabled(fMachineInValidMode);
+    m_pLabelEncryption->setEnabled(fMachineInValidMode);
+    m_pFieldEncryption->setEnabled(fMachineInValidMode);
+
+    /* Update remaining stuff: */
+    sltUpdateActionStates();
+    sltGetInformation();
 }
 
 void UIStorageSettingsEditor::setChipsetType(KChipsetType enmType)
 {
-    if (m_pModelStorage)
-    {
-        /* Make sure chipset type has changed: */
-        if (m_pModelStorage->chipsetType() != enmType)
-        {
-            /* Update chipset type value: */
-            m_pModelStorage->setChipsetType(enmType);
-            sltUpdateActionStates();
-
-            /* Notify listeners: */
-            emit sigValueChanged();
-        }
-    }
+    /* Check whether update is required: */
+    AssertPtrReturnVoid(m_pModelStorage);
+    if (m_pModelStorage->chipsetType() == enmType)
+        return;
+
+    /* Update chipset type value: */
+    m_pModelStorage->setChipsetType(enmType);
+    sltUpdateActionStates();
+
+    /* Notify listeners: */
+    emit sigValueChanged();
 }
 
 KChipsetType UIStorageSettingsEditor::chipsetType() const
 {
-    return m_pModelStorage ? m_pModelStorage->chipsetType() : KChipsetType_Null;
+    AssertPtrReturn(m_pModelStorage, KChipsetType_Null);
+    return m_pModelStorage->chipsetType();
 }
 
 QMap<KStorageBus, int> UIStorageSettingsEditor::currentControllerTypes() const
 {
+    AssertPtr(m_pModelStorage);
     return m_pModelStorage ? m_pModelStorage->currentControllerTypes() : QMap<KStorageBus, int>();
 }
@@ -3143,4 +3143,5 @@
 QMap<KStorageBus, int> UIStorageSettingsEditor::maximumControllerTypes() const
 {
+    AssertPtr(m_pModelStorage);
     return m_pModelStorage ? m_pModelStorage->maximumControllerTypes() : QMap<KStorageBus, int>();
 }
@@ -3150,4 +3151,5 @@
 {
     /* Clear model initially: */
+    AssertPtrReturnVoid(m_pModelStorage);
     m_pModelStorage->clear();
 
@@ -3200,4 +3202,5 @@
 {
     /* For each controller: */
+    AssertPtrReturnVoid(m_pModelStorage);
     const QModelIndex rootIndex = m_pModelStorage->root();
     for (int iControllerIndex = 0; iControllerIndex < m_pModelStorage->rowCount(rootIndex); ++iControllerIndex)
@@ -3339,7 +3342,9 @@
 void UIStorageSettingsEditor::sltHandleMediumEnumerated(const QUuid &uMediumId)
 {
+    /* Acquire newly recached medium: */
+    const UIMedium medium = uiCommon().medium(uMediumId);
+
     /* Search for corresponding medium: */
-    const UIMedium medium = uiCommon().medium(uMediumId);
-
+    AssertPtrReturnVoid(m_pModelStorage);
     const QModelIndex rootIndex = m_pModelStorage->root();
     for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i)
@@ -3363,4 +3368,6 @@
 void UIStorageSettingsEditor::sltHandleMediumDeleted(const QUuid &uMediumId)
 {
+    /* Search for corresponding medium: */
+    AssertPtrReturnVoid(m_pModelStorage);
     QModelIndex rootIndex = m_pModelStorage->root();
     for (int i = 0; i < m_pModelStorage->rowCount(rootIndex); ++i)
@@ -3459,8 +3466,10 @@
 void UIStorageSettingsEditor::sltRemoveController()
 {
+    AssertPtrReturnVoid(m_pTreeViewStorage);
     const QModelIndex index = m_pTreeViewStorage->currentIndex();
-    if (!m_pModelStorage->data(index, StorageModel::R_IsController).toBool())
-        return;
-
+    AssertPtrReturnVoid(m_pModelStorage);
+    AssertReturnVoid(m_pModelStorage->data(index, StorageModel::R_IsController).toBool());
+
+    /* Remove controller: */
     m_pModelStorage->delController(m_pModelStorage->data(index, StorageModel::R_ItemId).toUuid());
 
@@ -3471,8 +3480,11 @@
 void UIStorageSettingsEditor::sltAddAttachment()
 {
+    AssertPtrReturnVoid(m_pTreeViewStorage);
     const QModelIndex index = m_pTreeViewStorage->currentIndex();
-    Assert(m_pModelStorage->data(index, StorageModel::R_IsController).toBool());
-
-    const DeviceTypeList deviceTypeList(m_pModelStorage->data(index, StorageModel::R_CtrDevices).value<DeviceTypeList>());
+    AssertPtrReturnVoid(m_pModelStorage);
+    AssertReturnVoid(m_pModelStorage->data(index, StorageModel::R_IsController).toBool());
+
+    /* Prepare menu: */
+    const DeviceTypeList deviceTypeList = m_pModelStorage->data(index, StorageModel::R_CtrDevices).value<DeviceTypeList>();
     const bool fJustTrigger = deviceTypeList.size() == 1;
     const bool fShowMenu = deviceTypeList.size() > 1;
@@ -3525,21 +3537,19 @@
 void UIStorageSettingsEditor::sltRemoveAttachment()
 {
+    AssertPtrReturnVoid(m_pTreeViewStorage);
     const QModelIndex index = m_pTreeViewStorage->currentIndex();
-
+    AssertPtrReturnVoid(m_pModelStorage);
+    AssertReturnVoid(m_pModelStorage->data(index, StorageModel::R_IsAttachment).toBool());
+    const QModelIndex parentIndex = index.parent();
+    AssertReturnVoid(m_pModelStorage->data(parentIndex, StorageModel::R_IsController).toBool());
+
+    /* Check if this would be the last DVD. If so let the user confirm this again. */
     const KDeviceType enmDeviceType = m_pModelStorage->data(index, StorageModel::R_AttDevice).value<KDeviceType>();
-    /* Check if this would be the last DVD. If so let the user confirm this again. */
     if (   enmDeviceType == KDeviceType_DVD
-        && deviceCount(KDeviceType_DVD) == 1)
-    {
-        if (!msgCenter().confirmRemovingOfLastDVDDevice(this))
-            return;
-    }
-
-    const QModelIndex parentIndex = index.parent();
-    if (!index.isValid() || !parentIndex.isValid() ||
-        !m_pModelStorage->data(index, StorageModel::R_IsAttachment).toBool() ||
-        !m_pModelStorage->data(parentIndex, StorageModel::R_IsController).toBool())
+        && deviceCount(KDeviceType_DVD) == 1
+        && !msgCenter().confirmRemovingOfLastDVDDevice(this))
         return;
 
+    /* Remove attachment: */
     m_pModelStorage->delAttachment(m_pModelStorage->data(parentIndex, StorageModel::R_ItemId).toUuid(),
                                    m_pModelStorage->data(index, StorageModel::R_ItemId).toUuid());
@@ -3553,8 +3563,10 @@
     m_fLoadingInProgress = true;
 
+    AssertPtrReturnVoid(m_pTreeViewStorage);
     const QModelIndex index = m_pTreeViewStorage->currentIndex();
+    AssertPtrReturnVoid(m_pModelStorage);
     if (!index.isValid() || index == m_pModelStorage->root())
     {
-        /* Showing Initial Page: */
+        /* Showing initial page: */
         m_pStackRightPane->setCurrentIndex(0);
     }
@@ -3565,5 +3577,5 @@
             case AbstractItem::Type_ControllerItem:
             {
-                /* Getting Controller Name: */
+                /* Getting controller name: */
                 const QString strCtrName = m_pModelStorage->data(index, StorageModel::R_CtrName).toString();
                 if (m_pEditorName->text() != strCtrName)
@@ -3577,5 +3589,5 @@
                 {
                     /* Getting controller types: */
-                    const ControllerTypeList controllerTypeList(m_pModelStorage->data(index, m_pModelStorage->busToRole(enmCurrentBus)).value<ControllerTypeList>());
+                    const ControllerTypeList controllerTypeList(m_pModelStorage->data(index, StorageModel::busToRole(enmCurrentBus)).value<ControllerTypeList>());
                     foreach (const KStorageControllerType &enmCurrentType, controllerTypeList)
                     {
@@ -3600,5 +3612,5 @@
                 m_pCheckBoxIoCache->setChecked(fUseIoCache);
 
-                /* Showing Controller Page: */
+                /* Showing controller page: */
                 m_pStackRightPane->setCurrentIndex(1);
                 break;
@@ -3606,5 +3618,5 @@
             case AbstractItem::Type_AttachmentItem:
             {
-                /* Getting Attachment Slot: */
+                /* Getting attachment slot: */
                 m_pComboSlot->clear();
                 const SlotsList slotsList(m_pModelStorage->data(index, StorageModel::R_AttSlots).value<SlotsList>());
@@ -3616,5 +3628,5 @@
                 m_pComboSlot->setToolTip(m_pComboSlot->itemText(m_pComboSlot->currentIndex()));
 
-                /* Getting Attachment Medium: */
+                /* Getting attachment medium: */
                 const KDeviceType enmDeviceType = m_pModelStorage->data(index, StorageModel::R_AttDevice).value<KDeviceType>();
                 switch (enmDeviceType)
@@ -3662,14 +3674,14 @@
                 m_pToolButtonOpen->setEnabled(fIsEditable);
 
-                /* Getting Passthrough state: */
+                /* Getting passthrough state: */
                 const bool fHostDrive = m_pModelStorage->data(index, StorageModel::R_AttIsHostDrive).toBool();
                 m_pCheckBoxPassthrough->setVisible(enmDeviceType == KDeviceType_DVD && fHostDrive);
                 m_pCheckBoxPassthrough->setChecked(fHostDrive && m_pModelStorage->data(index, StorageModel::R_AttIsPassthrough).toBool());
 
-                /* Getting TempEject state: */
+                /* Getting temp-eject state: */
                 m_pCheckBoxTempEject->setVisible(enmDeviceType == KDeviceType_DVD && !fHostDrive);
                 m_pCheckBoxTempEject->setChecked(!fHostDrive && m_pModelStorage->data(index, StorageModel::R_AttIsTempEject).toBool());
 
-                /* Getting NonRotational state: */
+                /* Getting non-rotational state: */
                 m_pCheckBoxNonRotational->setVisible(enmDeviceType == KDeviceType_HardDisk);
                 m_pCheckBoxNonRotational->setChecked(m_pModelStorage->data(index, StorageModel::R_AttIsNonRotational).toBool());
@@ -3695,5 +3707,5 @@
                 m_pFieldEncryption->setVisible(enmDeviceType == KDeviceType_HardDisk);
 
-                /* Getting Other Information: */
+                /* Getting other information: */
                 m_pFieldHDFormat->setText(compressText(m_pModelStorage->data(index, StorageModel::R_AttFormat).toString()));
                 m_pFieldCDFDType->setText(compressText(m_pModelStorage->data(index, StorageModel::R_AttFormat).toString()));
@@ -3706,5 +3718,5 @@
                 m_pFieldEncryption->setText(compressText(m_pModelStorage->data(index, StorageModel::R_AttEncryptionPasswordID).toString()));
 
-                /* Showing Attachment Page: */
+                /* Showing attachment page: */
                 m_pStackRightPane->setCurrentIndex(2);
                 break;
@@ -3723,5 +3735,7 @@
 void UIStorageSettingsEditor::sltSetInformation()
 {
+    AssertPtrReturnVoid(m_pTreeViewStorage);
     const QModelIndex index = m_pTreeViewStorage->currentIndex();
+    AssertPtrReturnVoid(m_pModelStorage);
     if (m_fLoadingInProgress || !index.isValid() || index == m_pModelStorage->root())
         return;
@@ -3732,8 +3746,8 @@
         case AbstractItem::Type_ControllerItem:
         {
-            /* Setting Controller Name: */
+            /* Setting controller name: */
             if (pSender == m_pEditorName)
                 m_pModelStorage->setData(index, m_pEditorName->text(), StorageModel::R_CtrName);
-            /* Setting Controller Sub-Type: */
+            /* Setting controller sub-type: */
             else if (pSender == m_pComboType)
             {
@@ -3753,5 +3767,5 @@
         case AbstractItem::Type_AttachmentItem:
         {
-            /* Setting Attachment Slot: */
+            /* Setting attachment slot: */
             if (pSender == m_pComboSlot)
             {
@@ -3763,5 +3777,5 @@
                 m_pTreeViewStorage->setCurrentIndex(theSameIndexAtNewPosition);
             }
-            /* Setting Attachment Medium: */
+            /* Setting attachment medium: */
             else if (pSender == m_pMediumIdHolder)
                 m_pModelStorage->setData(index, m_pMediumIdHolder->id(), StorageModel::R_AttMediumId);
@@ -3925,6 +3939,9 @@
 void UIStorageSettingsEditor::sltUpdateActionStates()
 {
+    AssertPtrReturnVoid(m_pTreeViewStorage);
     const QModelIndex index = m_pTreeViewStorage->currentIndex();
 
+    /* Acquire options: */
+    AssertPtrReturnVoid(m_pModelStorage);
     const bool fIDEPossible = m_pModelStorage->data(index, StorageModel::R_IsMoreIDEControllersPossible).toBool();
     const bool fSATAPossible = m_pModelStorage->data(index, StorageModel::R_IsMoreSATAControllersPossible).toBool();
@@ -3935,5 +3952,4 @@
     const bool fNVMePossible = m_pModelStorage->data(index, StorageModel::R_IsMoreNVMeControllersPossible).toBool();
     const bool fVirtioSCSIPossible = m_pModelStorage->data(index, StorageModel::R_IsMoreVirtioSCSIControllersPossible).toBool();
-
     const bool fController = m_pModelStorage->data(index, StorageModel::R_IsController).toBool();
     const bool fAttachment = m_pModelStorage->data(index, StorageModel::R_IsAttachment).toBool();
@@ -3975,4 +3991,6 @@
 void UIStorageSettingsEditor::sltHandleRowInsertion(const QModelIndex &parentIndex, int iPosition)
 {
+    AssertPtrReturnVoid(m_pModelStorage);
+    AssertPtrReturnVoid(m_pTreeViewStorage);
     const QModelIndex index = m_pModelStorage->index(iPosition, 0, parentIndex);
 
@@ -4002,6 +4020,9 @@
 void UIStorageSettingsEditor::sltHandleRowRemoval()
 {
-    if (m_pModelStorage->rowCount (m_pModelStorage->root()) == 0)
-        m_pTreeViewStorage->setCurrentIndex (m_pModelStorage->root());
+    /* If no items left => just choose the root to be currnt: */
+    AssertPtrReturnVoid(m_pModelStorage);
+    AssertPtrReturnVoid(m_pTreeViewStorage);
+    if (m_pModelStorage->rowCount(m_pModelStorage->root()) == 0)
+        m_pTreeViewStorage->setCurrentIndex(m_pModelStorage->root());
 
     sltUpdateActionStates();
@@ -4020,4 +4041,5 @@
     m_mousePressPosition = QPoint();
 
+    AssertPtrReturnVoid(m_pTreeViewStorage);
     const QModelIndex index = m_pTreeViewStorage->indexAt(position);
     if (!index.isValid())
@@ -4025,4 +4047,5 @@
 
     QMenu menu;
+    AssertPtrReturnVoid(m_pModelStorage);
     switch (m_pModelStorage->data(index, StorageModel::R_ItemType).value<AbstractItem::ItemType>())
     {
@@ -4064,4 +4087,6 @@
 void UIStorageSettingsEditor::sltHandleDrawItemBranches(QPainter *pPainter, const QRect &rect, const QModelIndex &index)
 {
+    /* Make sure we are painting branches for attachments only,
+     * i.e. for items which have parent which have parent as well: */
     if (!index.parent().isValid() || !index.parent().parent().isValid())
         return;
@@ -4069,7 +4094,9 @@
     pPainter->save();
     QStyleOption options;
+    AssertPtrReturnVoid(m_pTreeViewStorage);
     options.initFrom(m_pTreeViewStorage);
     options.rect = rect;
     options.state |= QStyle::State_Item;
+    AssertPtrReturnVoid(m_pModelStorage);
     if (index.row() < m_pModelStorage->rowCount(index.parent()) - 1)
         options.state |= QStyle::State_Sibling;
@@ -4091,8 +4118,10 @@
     const QPoint lPos = pEvent->position().toPoint();
 
+    AssertPtrReturnVoid(m_pTreeViewStorage);
     const QModelIndex index = m_pTreeViewStorage->indexAt(lPos);
     const QRect indexRect = m_pTreeViewStorage->visualRect(index);
 
     /* Expander tool-tip: */
+    AssertPtrReturnVoid(m_pModelStorage);
     if (m_pModelStorage->data(index, StorageModel::R_IsController).toBool())
     {
@@ -4221,4 +4250,5 @@
 
     /* Acquire indexes: */
+    AssertPtrReturnVoid(m_pTreeViewStorage);
     const QModelIndex currentIndex = m_pTreeViewStorage->currentIndex();
     const QModelIndex index = m_pTreeViewStorage->indexAt(lPos);
@@ -4230,4 +4260,5 @@
 
     /* Expander icon: */
+    AssertPtrReturnVoid(m_pModelStorage);
     if (m_pModelStorage->data(index, StorageModel::R_IsController).toBool())
     {
@@ -5054,4 +5085,5 @@
 {
 #ifdef RT_STRICT
+    AssertPtrReturnVoid(m_pTreeViewStorage);
     const QModelIndex index = m_pTreeViewStorage->currentIndex();
     switch (enmBus)
@@ -5086,5 +5118,9 @@
 #endif
 
+    /* Add controller: */
+    AssertPtrReturnVoid(m_pModelStorage);
     m_pModelStorage->addController(strName, enmBus, enmType);
+
+    /* Notify listeners: */
     emit sigValueChanged();
 }
@@ -5092,4 +5128,5 @@
 void UIStorageSettingsEditor::addAttachmentWrapper(KDeviceType enmDeviceType)
 {
+    AssertPtrReturnVoid(m_pTreeViewStorage);
     const QModelIndex index = m_pTreeViewStorage->currentIndex();
     Assert(m_pModelStorage->data(index, StorageModel::R_IsController).toBool());
@@ -5115,4 +5152,6 @@
         return;
 
+    /* Add attachment: */
+    AssertPtrReturnVoid(m_pModelStorage);
     m_pModelStorage->addAttachment(m_pModelStorage->data(index, StorageModel::R_ItemId).toUuid(), enmDeviceType, uMediumId);
     m_pModelStorage->sort();
@@ -5124,4 +5163,5 @@
 QString UIStorageSettingsEditor::generateUniqueControllerName(const QString &strTemplate) const
 {
+    AssertPtrReturn(m_pModelStorage, QString());
     int iMaxNumber = 0;
     const QModelIndex rootIndex = m_pModelStorage->root();
@@ -5143,4 +5183,5 @@
 uint32_t UIStorageSettingsEditor::deviceCount(KDeviceType enmType) const
 {
+    AssertPtrReturn(m_pModelStorage, 0);
     uint32_t cDevices = 0;
     const QModelIndex rootIndex = m_pModelStorage->root();
