Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp	(revision 46703)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp	(revision 46704)
@@ -268,5 +268,5 @@
     {
         /* Parse the close-action which was defined: */
-        closeAction = UIVMCloseDialog::parseResultCode(strDefaultAction);
+        closeAction = gpConverter->fromInternalString<MachineCloseAction>(strDefaultAction);
         /* If VM is stuck, and the default close-action is not 'power-off',
          * we should ask the user about what to do: */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp	(revision 46703)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp	(revision 46704)
@@ -36,4 +36,5 @@
 # include "VBoxGlobal.h"
 # include "QIDialogButtonBox.h"
+# include "UIConverter.h"
 
 /* COM includes: */
@@ -46,10 +47,7 @@
 UIVMCloseDialog::UIVMCloseDialog(QWidget *pParent, const CMachine &machine, const CSession &session)
     : QIWithRetranslateUI<QIDialog>(pParent)
-    , m_strExtraDataOptionSave("save")
-    , m_strExtraDataOptionShutdown("shutdown")
-    , m_strExtraDataOptionPowerOff("powerOff")
-    , m_strExtraDataOptionDiscard("discardCurState")
     , m_fValid(false)
     , m_fIsACPIEnabled(false)
+    , m_lastCloseAction(MachineCloseAction_Invalid)
 {
     /* Prepare: */
@@ -62,17 +60,4 @@
     /* Retranslate finally: */
     retranslateUi();
-}
-
-/* static */
-MachineCloseAction UIVMCloseDialog::parseResultCode(const QString &strCloseAction)
-{
-    MachineCloseAction closeAction = MachineCloseAction_Invalid;
-    if (!strCloseAction.compare("Save", Qt::CaseInsensitive))
-        closeAction = MachineCloseAction_Save;
-    else if (!strCloseAction.compare("Shutdown", Qt::CaseInsensitive))
-        closeAction = MachineCloseAction_Shutdown;
-    else if (!strCloseAction.compare("PowerOff", Qt::CaseInsensitive))
-        closeAction = MachineCloseAction_PowerOff;
-    return closeAction;
 }
 
@@ -98,36 +83,11 @@
     }
 
-    /* Read the last user's choice for the given VM: */
-    QStringList previousChoice = m_machine.GetExtraData(GUI_LastCloseAction).split(',');
     /* Memorize the last user's choice for the given VM: */
-    QString strLastAction = m_strExtraDataOptionPowerOff;
-    switch (result())
-    {
-        case MachineCloseAction_Save:
-        {
-            strLastAction = m_strExtraDataOptionSave;
-            break;
-        }
-        case MachineCloseAction_Shutdown:
-        {
-            strLastAction = m_strExtraDataOptionShutdown;
-            break;
-        }
-        case MachineCloseAction_PowerOff:
-        {
-            if (previousChoice[0] == m_strExtraDataOptionShutdown && !m_fIsACPIEnabled)
-                strLastAction = m_strExtraDataOptionShutdown;
-            else
-                strLastAction = m_strExtraDataOptionPowerOff;
-            break;
-        }
-        case MachineCloseAction_PowerOff_RestoringSnapshot:
-        {
-            strLastAction = m_strExtraDataOptionPowerOff + "," +
-                            m_strExtraDataOptionDiscard;
-        }
-        default: break;
-    }
-    m_machine.SetExtraData(GUI_LastCloseAction, strLastAction);
+    MachineCloseAction newCloseAction = static_cast<MachineCloseAction>(result());
+    /* But make sure 'Shutdown' is preserved if temporary unavailable: */
+    if (newCloseAction == MachineCloseAction_PowerOff &&
+        m_lastCloseAction == MachineCloseAction_Shutdown && !m_fIsACPIEnabled)
+        newCloseAction = MachineCloseAction_Shutdown;
+    m_machine.SetExtraData(GUI_LastCloseAction, gpConverter->toInternalString(newCloseAction));
 
     /* Hide the dialog: */
@@ -344,31 +304,32 @@
         m_strDiscardCheckBoxText = m_machine.GetCurrentSnapshot().GetName();
 
-    /* Read the last user's choice for the given VM: */
-    QStringList lastAction = m_machine.GetExtraData(GUI_LastCloseAction).split(',');
-
     /* Check which radio-button should be initially chosen: */
     QRadioButton *pRadioButtonToChoose = 0;
     /* If choosing 'last choice' is possible: */
-    if (lastAction[0] == m_strExtraDataOptionSave && fIsStateSavingAllowed)
+    m_lastCloseAction = gpConverter->fromInternalString<MachineCloseAction>(m_machine.GetExtraData(GUI_LastCloseAction));
+    if (m_lastCloseAction == MachineCloseAction_Save && fIsStateSavingAllowed)
     {
         pRadioButtonToChoose = m_pSaveRadio;
     }
-    else if (lastAction[0] == m_strExtraDataOptionShutdown && fIsACPIShutdownAllowed && m_fIsACPIEnabled)
+    else if (m_lastCloseAction == MachineCloseAction_Shutdown && fIsACPIShutdownAllowed && m_fIsACPIEnabled)
     {
         pRadioButtonToChoose = m_pShutdownRadio;
     }
-    else if (lastAction[0] == m_strExtraDataOptionPowerOff && fIsPowerOffAllowed)
+    else if (m_lastCloseAction == MachineCloseAction_PowerOff && fIsPowerOffAllowed)
     {
         pRadioButtonToChoose = m_pPowerOffRadio;
-        if (fIsPowerOffAndRestoreAllowed)
-            m_pDiscardCheckBox->setChecked(lastAction.count() > 1 && lastAction[1] == m_strExtraDataOptionDiscard);
+    }
+    else if (m_lastCloseAction == MachineCloseAction_PowerOff_RestoringSnapshot && fIsPowerOffAndRestoreAllowed)
+    {
+        pRadioButtonToChoose = m_pPowerOffRadio;
+        m_pDiscardCheckBox->setChecked(true);
     }
     /* Else 'default choice' will be used: */
     else
     {
-        if (fIsACPIShutdownAllowed && m_fIsACPIEnabled)
+        if (fIsStateSavingAllowed)
+            pRadioButtonToChoose = m_pSaveRadio;
+        else if (fIsACPIShutdownAllowed && m_fIsACPIEnabled)
             pRadioButtonToChoose = m_pShutdownRadio;
-        else if (fIsStateSavingAllowed)
-            pRadioButtonToChoose = m_pSaveRadio;
         else if (fIsPowerOffAllowed)
             pRadioButtonToChoose = m_pPowerOffRadio;
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h	(revision 46703)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h	(revision 46704)
@@ -48,7 +48,4 @@
     bool isValid() const { return m_fValid; }
 
-    /* Static API: Parse string containing result-code: */
-    static MachineCloseAction parseResultCode(const QString &strCloseAction);
-
 private slots:
 
@@ -98,12 +95,9 @@
 
     /* Variables: */
-    const QString m_strExtraDataOptionSave;
-    const QString m_strExtraDataOptionShutdown;
-    const QString m_strExtraDataOptionPowerOff;
-    const QString m_strExtraDataOptionDiscard;
     bool m_fValid;
     CMachine m_machine;
     bool m_fIsACPIEnabled;
     QString m_strDiscardCheckBoxText;
+    MachineCloseAction m_lastCloseAction;
 };
 
