Index: trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDiskImageManagerDlg.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDiskImageManagerDlg.h	(revision 10971)
+++ trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDiskImageManagerDlg.h	(revision 10999)
@@ -49,5 +49,5 @@
     VBoxDiskImageManagerDlg (QWidget *aParent = NULL, Qt::WindowFlags aFlags = Qt::Dialog);
 
-    void setup (int aType, bool aDoSelect, const QUuid *aTargetVMId = NULL, bool aRefresh = true, CMachine aMachine = NULL, const QUuid & aHdId = QUuid(), const QUuid & aCdId = QUuid(), const QUuid & aFdId = QUuid());
+    void setup (int aType, bool aDoSelect, const QUuid &aTargetVMId = QUuid(), bool aRefresh = true, CMachine aMachine = NULL, const QUuid &aHdId = QUuid(), const QUuid &aCdId = QUuid(), const QUuid &aFdId = QUuid());
 
     static void showModeless (bool aRefresh = true);
Index: trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMSettingsHD.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMSettingsHD.h	(revision 10971)
+++ trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMSettingsHD.h	(revision 10999)
@@ -287,4 +287,6 @@
 signals:
 
+    void signalToCloseEditor (QWidget *aEditor,
+                              QAbstractItemDelegate::EndEditHint aCloseHint);
     void hdChanged();
 
Index: trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleWnd.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleWnd.cpp	(revision 10971)
+++ trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleWnd.cpp	(revision 10999)
@@ -2578,6 +2578,5 @@
 
     VBoxDiskImageManagerDlg dlg (this);
-    QUuid id = csession.GetMachine().GetId();
-    dlg.setup (VBoxDefs::FD, true, &id);
+    dlg.setup (VBoxDefs::FD, true, csession.GetMachine().GetId());
 
     if (dlg.exec() == QDialog::Accepted)
@@ -2622,6 +2621,5 @@
 
     VBoxDiskImageManagerDlg dlg (this);
-    QUuid id = csession.GetMachine().GetId();
-    dlg.setup (VBoxDefs::CD, true, &id);
+    dlg.setup (VBoxDefs::CD, true, csession.GetMachine().GetId());
 
     if (dlg.exec() == QDialog::Accepted)
Index: trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDiskImageManagerDlg.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDiskImageManagerDlg.cpp	(revision 10971)
+++ trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDiskImageManagerDlg.cpp	(revision 10999)
@@ -447,5 +447,5 @@
 
 void VBoxDiskImageManagerDlg::setup (int aType, bool aDoSelect,
-                                     const QUuid *aTargetVMId /* = NULL */,
+                                     const QUuid &aTargetVMId /* = NULL */,
                                      bool aRefresh /* = true */,
                                      CMachine aMachine /* = NULL */,
@@ -465,6 +465,6 @@
 
     mDoSelect = aDoSelect;
-    if (aTargetVMId)
-        mTargetVMId = *aTargetVMId;
+    if (!aTargetVMId.isNull())
+        mTargetVMId = aTargetVMId;
 
     if (mDoSelect)
Index: trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMFirstRunWzd.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMFirstRunWzd.cpp	(revision 10971)
+++ trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMFirstRunWzd.cpp	(revision 10999)
@@ -242,8 +242,7 @@
 {
     VBoxDiskImageManagerDlg vdm (this);
-    QUuid machineId = mMachine.GetId();
     VBoxDefs::DiskType type = mRbCdType->isChecked() ? VBoxDefs::CD :
         mRbFdType->isChecked() ? VBoxDefs::FD : VBoxDefs::InvalidType;
-    vdm.setup (type, true, &machineId);
+    vdm.setup (type, true, mMachine.GetId());
     if (vdm.exec() == QDialog::Accepted)
     {
Index: trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsCD.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsCD.cpp	(revision 10971)
+++ trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsCD.cpp	(revision 10999)
@@ -248,6 +248,5 @@
     QUuid oldId = mUuidIsoCD;
     VBoxDiskImageManagerDlg dlg (this);
-    QUuid machineId = mMachine.GetId();
-    dlg.setup (VBoxDefs::CD, true, &machineId, true /* aRefresh */,
+    dlg.setup (VBoxDefs::CD, true, mMachine.GetId(), true /* aRefresh */,
                mMachine, QUuid(), mCbIsoCD->getId(), QUuid());
 
Index: trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsFD.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsFD.cpp	(revision 10971)
+++ trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsFD.cpp	(revision 10999)
@@ -244,6 +244,5 @@
     QUuid oldId = mUuidIsoFD;
     VBoxDiskImageManagerDlg dlg (this);
-    QUuid machineId = mMachine.GetId();
-    dlg.setup (VBoxDefs::FD, true, &machineId, true /* aRefresh */,
+    dlg.setup (VBoxDefs::FD, true, mMachine.GetId(), true /* aRefresh */,
                mMachine, QUuid(), mCbIsoFD->getId(), QUuid());
 
Index: trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsHD.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsHD.cpp	(revision 10971)
+++ trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMSettingsHD.cpp	(revision 10999)
@@ -260,4 +260,5 @@
     : VBoxMediaComboBox (aParent, VBoxDefs::HD)
 {
+    mInstance = this;
     setBelongsTo (HDSlotUniquizer::instance()->machine().GetId());
     connect (this, SIGNAL (currentIndexChanged (int)), this, SLOT (onActivate()));
@@ -265,9 +266,9 @@
              parent()->parent(), SLOT (commitData (QWidget *)));
     refresh();
-    mInstance = this;
 }
 HDVdiEditor::~HDVdiEditor()
 {
-    mInstance = 0;
+    if (mInstance == this)
+        mInstance = 0;
 }
 
@@ -468,4 +469,6 @@
              SIGNAL (mediaRemoved (VBoxDefs::DiskType, const QUuid &)),
              this, SLOT (onMediaRemoved (VBoxDefs::DiskType, const QUuid &)));
+    connect (this, SIGNAL (signalToCloseEditor (QWidget*, QAbstractItemDelegate::EndEditHint)),
+             mTwAts, SLOT (closeEditor (QWidget*, QAbstractItemDelegate::EndEditHint)));
 
     /* Install global event filter */
@@ -650,5 +653,9 @@
         if (result == QIMessageBox::Yes)
         {
-            mTwAts->closePersistentEditor (mTwAts->currentIndex());
+            /* Close the editor to avoid it's infliction to data model */
+            emit signalToCloseEditor (HDVdiEditor::activeEditor(),
+                                      QAbstractItemDelegate::NoHint);
+
+            /* Run new HD wizard */
             VBoxNewHDWzd dlg (this);
             if (dlg.exec() == QDialog::Accepted)
@@ -703,17 +710,23 @@
     Assert (mTwAts->currentIndex().isValid());
 
+    /* Close the editor to avoid it's infliction to data model */
+    emit signalToCloseEditor (HDVdiEditor::activeEditor(),
+                              QAbstractItemDelegate::NoHint);
+
+    HDVdiValue oldVdi (mModel->data (mTwAts->currentIndex(), Qt::EditRole)
+                       .value<HDVdiValue>());
+
     VBoxDiskImageManagerDlg dlg (this);
-    QUuid machineId = mMachine.GetId();
-    HDVdiValue vdiInfo (mModel->data (mTwAts->currentIndex(), Qt::EditRole)
-                        .value<HDVdiValue>());
-    QUuid hdId = vdiInfo.id;
-    dlg.setup (VBoxDefs::HD, true, &machineId, true, mMachine, hdId);
+    dlg.setup (VBoxDefs::HD, true, mMachine.GetId(), true, mMachine, oldVdi.id);
 
     if (dlg.exec() == QDialog::Accepted)
     {
+        /* Compose resulting vdi */
         QVariant result;
-        HDVdiValue val (VBoxMediaComboBox::fullItemName (dlg.selectedPath()),
-                        dlg.selectedUuid());
-        result.setValue (val);
+        HDVdiValue newVdi (VBoxMediaComboBox::fullItemName (dlg.selectedPath()),
+                           dlg.selectedUuid());
+        result.setValue (newVdi);
+
+        /* Set the model's data */
         mModel->setData (mTwAts->currentIndex(), result);
     }
@@ -722,10 +735,11 @@
 }
 
-void VBoxVMSettingsHD::onCurrentChanged (const QModelIndex &aIndex)
+void VBoxVMSettingsHD::onCurrentChanged (const QModelIndex& /* aIndex */)
 {
     mNewAction->setEnabled (mModel->rowCount() - 1 <
         HDSlotUniquizer::instance()->list (HDSltValue(), false).count());
     mDelAction->setEnabled (mTwAts->currentIndex().row() != mModel->rowCount() - 1);
-    mVdmAction->setEnabled (aIndex.isValid() && aIndex.column() == 1);
+    mVdmAction->setEnabled (mTwAts->currentIndex().row() != mModel->rowCount() - 1 &&
+                            mTwAts->currentIndex().column() == 1);
 }
 
@@ -744,6 +758,5 @@
         if (firstSataPort < list.size())
         {
-            int rc = vboxProblem().confirmDetachSATASlots (this);
-            if (rc != QIMessageBox::Ok)
+            if (vboxProblem().confirmDetachSATASlots (this) != QIMessageBox::Ok)
             {
                 /* Switch check-box back to "Qt::Checked" */
@@ -757,4 +770,8 @@
                 /* Delete SATA items */
                 mModel->removeSata();
+
+                /* Set column #1 of first index to be the current */
+                mTwAts->setCurrentIndex (mModel->index (0, 1));
+
                 if (mValidator)
                     mValidator->revalidate();
