Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp	(revision 53013)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp	(revision 53028)
@@ -58,12 +58,7 @@
 
 /* COM includes: */
-# include "CConsole.h"
 # include "CSystemProperties.h"
-# include "CMachineDebugger.h"
-# include "CGuest.h"
 # include "CStorageController.h"
 # include "CMediumAttachment.h"
-# include "CDisplay.h"
-# include "CMouse.h"
 # include "CNetworkAdapter.h"
 # include "CHostNetworkInterface.h"
@@ -168,24 +163,19 @@
         return;
 
-    /* Get current machine/console: */
-    CMachine machine = session().GetMachine();
-    CConsole console = session().GetConsole();
-
     /* Apply debug settings from the command line. */
-    CMachineDebugger debugger = console.GetDebugger();
-    if (debugger.isOk())
+    if (debugger().isOk())
     {
         if (vboxGlobal().isPatmDisabled())
-            debugger.SetPATMEnabled(false);
+            debugger().SetPATMEnabled(false);
         if (vboxGlobal().isCsamDisabled())
-            debugger.SetCSAMEnabled(false);
+            debugger().SetCSAMEnabled(false);
         if (vboxGlobal().isSupervisorCodeExecedRecompiled())
-            debugger.SetRecompileSupervisor(true);
+            debugger().SetRecompileSupervisor(true);
         if (vboxGlobal().isUserCodeExecedRecompiled())
-            debugger.SetRecompileUser(true);
+            debugger().SetRecompileUser(true);
         if (vboxGlobal().areWeToExecuteAllInIem())
-            debugger.SetExecuteAllInIEM(true);
+            debugger().SetExecuteAllInIEM(true);
         if (!vboxGlobal().isDefaultWarpPct())
-            debugger.SetVirtualTimeRate(vboxGlobal().getWarpPct());
+            debugger().SetVirtualTimeRate(vboxGlobal().getWarpPct());
     }
 
@@ -195,14 +185,14 @@
 #ifdef VBOX_WITH_DEBUGGER_GUI
         CProgress progress = vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled() ?
-                             console.PowerUpPaused() : console.PowerUp();
+                             console().PowerUpPaused() : console().PowerUp();
 #else /* !VBOX_WITH_DEBUGGER_GUI */
-        CProgress progress = console.PowerUp();
+        CProgress progress = console().PowerUp();
 #endif /* !VBOX_WITH_DEBUGGER_GUI */
 
         /* Check for immediate failure: */
-        if (!console.isOk())
+        if (!console().isOk())
         {
             if (vboxGlobal().showStartVMErrors())
-                msgCenter().cannotStartMachine(console, machine.GetName());
+                msgCenter().cannotStartMachine(console(), machineName());
             closeRuntimeUI();
             return;
@@ -216,10 +206,10 @@
         if (isSaved())
         {
-            msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_state_restore_90px.png", 0, 0);
+            msgCenter().showModalProgressDialog(progress, machineName(), ":/progress_state_restore_90px.png", 0, 0);
             /* After restoring from 'saved' state, machine-window(s) geometry should be adjusted: */
             machineLogic()->adjustMachineWindowsGeometry();
         }
         else
-            msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_start_90px.png");
+            msgCenter().showModalProgressDialog(progress, machineName(), ":/progress_start_90px.png");
 
         /* Check for a progress failure: */
@@ -227,5 +217,5 @@
         {
             if (vboxGlobal().showStartVMErrors())
-                msgCenter().cannotStartMachine(progress, machine.GetName());
+                msgCenter().cannotStartMachine(progress, machineName());
             closeRuntimeUI();
             return;
@@ -238,11 +228,10 @@
     else
     {
-        /* Fetch the current state: */
-        CMouse mouse = console.GetMouse();
-        m_fIsMouseSupportsAbsolute = mouse.GetAbsoluteSupported();
-        m_fIsMouseSupportsRelative = mouse.GetRelativeSupported();
-        m_fIsMouseSupportsMultiTouch = mouse.GetMultiTouchSupported();
-        m_fIsMouseHostCursorNeeded = mouse.GetNeedsHostCursor();
-
+        /* Fetch the current mouse state: */
+        m_fIsMouseSupportsAbsolute = mouse().GetAbsoluteSupported();
+        m_fIsMouseSupportsRelative = mouse().GetRelativeSupported();
+        m_fIsMouseSupportsMultiTouch = mouse().GetMultiTouchSupported();
+        m_fIsMouseHostCursorNeeded = mouse().GetNeedsHostCursor();
+        /* Fetch the current guest additions state: */
         sltAdditionsChange();
     }
@@ -255,10 +244,9 @@
     }
 
-    /* Check if the required virtualization features are active. We get this
-     * info only when the session is active. */
-    bool fIs64BitsGuest = vboxGlobal().virtualBox().GetGuestOSType(console.GetGuest().GetOSTypeId()).GetIs64Bit();
-    bool fRecommendVirtEx = vboxGlobal().virtualBox().GetGuestOSType(console.GetGuest().GetOSTypeId()).GetRecommendedVirtEx();
+    /* Check if the required virtualization features are active. We get this info only when the session is active. */
+    const bool fIs64BitsGuest = vboxGlobal().virtualBox().GetGuestOSType(guest().GetOSTypeId()).GetIs64Bit();
+    const bool fRecommendVirtEx = vboxGlobal().virtualBox().GetGuestOSType(guest().GetOSTypeId()).GetRecommendedVirtEx();
     AssertMsg(!fIs64BitsGuest || fRecommendVirtEx, ("Virtualization support missed for 64bit guest!\n"));
-    bool fIsVirtEnabled = console.GetDebugger().GetHWVirtExEnabled();
+    bool fIsVirtEnabled = debugger().GetHWVirtExEnabled();
     if (fRecommendVirtEx && !fIsVirtEnabled)
     {
@@ -277,8 +265,8 @@
         if (fShouldWeClose)
         {
-            /* At this point the console is powered up. So we have to close
-             * this session again. */
-            CProgress progress = console.PowerDown();
-            if (console.isOk())
+            /* At this point the console is powered up.
+             * So we have to close this session again. */
+            CProgress progress = console().PowerDown();
+            if (console().isOk())
             {
                 /* Guard progressbar warnings from auto-closing: */
@@ -286,7 +274,7 @@
                     uimachine()->machineLogic()->setPreventAutoClose(true);
                 /* Show the power down progress dialog */
-                msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_poweroff_90px.png");
+                msgCenter().showModalProgressDialog(progress, machineName(), ":/progress_poweroff_90px.png");
                 if (!progress.isOk() || progress.GetResultCode() != 0)
-                    msgCenter().cannotPowerDownMachine(progress, machine.GetName());
+                    msgCenter().cannotPowerDownMachine(progress, machineName());
                 /* Allow further auto-closing: */
                 if (uimachine()->machineLogic())
@@ -294,5 +282,5 @@
             }
             else
-                msgCenter().cannotPowerDownMachine(console);
+                msgCenter().cannotPowerDownMachine(console());
             closeRuntimeUI();
             return;
@@ -304,8 +292,8 @@
 #ifdef VBOX_WITH_VIDEOHWACCEL
     LogRel(("2D video acceleration is %s.\n",
-           machine.GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable()
+           machine().GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable()
                  ? "enabled"
                  : "disabled"));
-#endif
+#endif /* VBOX_WITH_VIDEOHWACCEL */
 
 /* Check if HID LEDs sync is enabled and add a log message about it. */
@@ -330,15 +318,13 @@
 {
     /* Prepare the saving progress: */
-    CMachine machine = m_session.GetMachine();
-    CConsole console = m_session.GetConsole();
-    CProgress progress = console.SaveState();
-    if (console.isOk())
+    CProgress progress = console().SaveState();
+    if (console().isOk())
     {
         /* Show the saving progress: */
-        msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_state_save_90px.png");
+        msgCenter().showModalProgressDialog(progress, machineName(), ":/progress_state_save_90px.png");
         if (!progress.isOk() || progress.GetResultCode() != 0)
         {
             /* Failed in progress: */
-            msgCenter().cannotSaveMachineState(progress, machine.GetName());
+            msgCenter().cannotSaveMachineState(progress, machineName());
             return false;
         }
@@ -347,5 +333,5 @@
     {
         /* Failed in console: */
-        msgCenter().cannotSaveMachineState(console);
+        msgCenter().cannotSaveMachineState(console());
         return false;
     }
@@ -357,10 +343,9 @@
 {
     /* Send ACPI shutdown signal if possible: */
-    CConsole console = m_session.GetConsole();
-    console.PowerButton();
-    if (!console.isOk())
+    console().PowerButton();
+    if (!console().isOk())
     {
         /* Failed in console: */
-        msgCenter().cannotACPIShutdownMachine(console);
+        msgCenter().cannotACPIShutdownMachine(console());
         return false;
     }
@@ -372,11 +357,9 @@
 {
     /* Prepare the power-off progress: */
-    CMachine machine = m_session.GetMachine();
-    CConsole console = m_session.GetConsole();
-    CProgress progress = console.PowerDown();
-    if (console.isOk())
+    CProgress progress = console().PowerDown();
+    if (console().isOk())
     {
         /* Show the power-off progress: */
-        msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_poweroff_90px.png");
+        msgCenter().showModalProgressDialog(progress, machineName(), ":/progress_poweroff_90px.png");
         if (progress.isOk() && progress.GetResultCode() == 0)
         {
@@ -385,13 +368,13 @@
             {
                 /* Prepare the snapshot-discard progress: */
-                CSnapshot snapshot = machine.GetCurrentSnapshot();
-                CProgress progress = console.RestoreSnapshot(snapshot);
-                if (!console.isOk())
-                    return msgCenter().cannotRestoreSnapshot(console, snapshot.GetName(), machine.GetName());
+                CSnapshot snapshot = machine().GetCurrentSnapshot();
+                CProgress progress = console().RestoreSnapshot(snapshot);
+                if (!console().isOk())
+                    return msgCenter().cannotRestoreSnapshot(console(), snapshot.GetName(), machineName());
 
                 /* Show the snapshot-discard progress: */
-                msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_snapshot_discard_90px.png");
+                msgCenter().showModalProgressDialog(progress, machineName(), ":/progress_snapshot_discard_90px.png");
                 if (progress.GetResultCode() != 0)
-                    return msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName(), machine.GetName());
+                    return msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName(), machineName());
             }
         }
@@ -399,5 +382,5 @@
         {
             /* Failed in progress: */
-            msgCenter().cannotPowerDownMachine(progress, machine.GetName());
+            msgCenter().cannotPowerDownMachine(progress, machineName());
             return false;
         }
@@ -406,13 +389,13 @@
     {
         /* Check the machine state, it might be already gone: */
-        if (!console.isNull())
+        if (!console().isNull())
         {
            /* Failed in console: */
-           COMResult res(console);
+           COMResult res(console());
            /* This can happen if VBoxSVC is not running: */
            if (FAILED_DEAD_INTERFACE(res.rc()))
                fServerCrashed = true;
            else
-               msgCenter().cannotPowerDownMachine(console);
+               msgCenter().cannotPowerDownMachine(console());
            return false;
         }
@@ -450,20 +433,16 @@
 bool UISession::setPause(bool fOn)
 {
-    CConsole console = session().GetConsole();
-    if (console.isNull())
-        return true;
-
     if (fOn)
-        console.Pause();
+        console().Pause();
     else
-        console.Resume();
-
-    bool ok = console.isOk();
+        console().Resume();
+
+    bool ok = console().isOk();
     if (!ok)
     {
         if (fOn)
-            msgCenter().cannotPauseMachine(console);
+            msgCenter().cannotPauseMachine(console());
         else
-            msgCenter().cannotResumeMachine(console);
+            msgCenter().cannotResumeMachine(console());
     }
 
@@ -481,10 +460,9 @@
     fDoMount = true;
 #else /* VBOX_WITH_ADDITIONS_AUTOUPDATE_UI */
-    CGuest guest = session().GetConsole().GetGuest();
     QVector<KAdditionsUpdateFlag> aFlagsUpdate;
     QVector<QString> aArgs;
-    CProgress progressInstall = guest.UpdateGuestAdditions(strSource,
-                                                           aArgs, aFlagsUpdate);
-    bool fResult = guest.isOk();
+    CProgress progressInstall = guest().UpdateGuestAdditions(strSource,
+                                                             aArgs, aFlagsUpdate);
+    bool fResult = guest().isOk();
     if (fResult)
     {
@@ -535,13 +513,10 @@
     AssertReturnVoid(!strMediumID.isNull());
 
-    /* Get machine: */
-    CMachine machine = session().GetMachine();
-
     /* Searching for the first suitable controller/slot: */
     QString strControllerName;
     LONG iCntPort = -1, iCntDevice = -1;
-    foreach (const CStorageController &controller, machine.GetStorageControllers())
-    {
-        foreach (const CMediumAttachment &attachment, machine.GetMediumAttachmentsOfController(controller.GetName()))
+    foreach (const CStorageController &controller, machine().GetStorageControllers())
+    {
+        foreach (const CMediumAttachment &attachment, machine().GetMediumAttachmentsOfController(controller.GetName()))
         {
             if (attachment.GetType() == KDeviceType_DVD)
@@ -560,5 +535,5 @@
     if (strControllerName.isNull())
     {
-        msgCenter().cannotMountGuestAdditions(machine.GetName());
+        msgCenter().cannotMountGuestAdditions(machineName());
         return;
     }
@@ -574,15 +549,15 @@
 
     /* Mount medium to corresponding controller/slot: */
-    machine.MountMedium(strControllerName, iCntPort, iCntDevice, medium.medium(), false /* force */);
-    if (!machine.isOk())
+    machine().MountMedium(strControllerName, iCntPort, iCntDevice, medium.medium(), false /* force */);
+    if (!machine().isOk())
     {
         /* Ask for force mounting: */
-        if (msgCenter().cannotRemountMedium(machine, medium, true /* mount? */,
+        if (msgCenter().cannotRemountMedium(machine(), medium, true /* mount? */,
                                             true /* retry? */, mainMachineWindow()))
         {
             /* Force mount medium to the predefined port/device: */
-            machine.MountMedium(strControllerName, iCntPort, iCntDevice, medium.medium(), true /* force */);
-            if (!machine.isOk())
-                msgCenter().cannotRemountMedium(machine, medium, true /* mount? */,
+            machine().MountMedium(strControllerName, iCntPort, iCntDevice, medium.medium(), true /* force */);
+            if (!machine().isOk())
+                msgCenter().cannotRemountMedium(machine(), medium, true /* mount? */,
                                                 false /* retry? */, mainMachineWindow());
         }
@@ -722,8 +697,6 @@
 void UISession::sltVRDEChange()
 {
-    /* Get machine: */
-    const CMachine machine = session().GetMachine();
     /* Get VRDE server: */
-    const CVRDEServer &server = machine.GetVRDEServer();
+    const CVRDEServer &server = machine().GetVRDEServer();
     bool fIsVRDEServerAvailable = !server.isNull();
     /* Show/Hide VRDE action depending on VRDE server availability status: */
@@ -740,8 +713,6 @@
 void UISession::sltVideoCaptureChange()
 {
-    /* Get machine: */
-    const CMachine machine = session().GetMachine();
     /* Check/Uncheck Video Capture action depending on feature status: */
-    actionPool()->action(UIActionIndexRT_M_Devices_M_VideoCapture_T_Start)->setChecked(machine.GetVideoCaptureEnabled());
+    actionPool()->action(UIActionIndexRT_M_Devices_M_VideoCapture_T_Start)->setChecked(machine().GetVideoCaptureEnabled());
     /* Notify listeners about Video Capture change: */
     emit sigVideoCaptureChange();
@@ -870,13 +841,10 @@
 void UISession::sltAdditionsChange()
 {
-    /* Get our guest: */
-    CGuest guest = session().GetConsole().GetGuest();
-
     /* Variable flags: */
-    ULONG ulGuestAdditionsRunLevel = guest.GetAdditionsRunLevel();
+    ULONG ulGuestAdditionsRunLevel = guest().GetAdditionsRunLevel();
     LONG64 lLastUpdatedIgnored;
-    bool fIsGuestSupportsGraphics = guest.GetFacilityStatus(KAdditionsFacilityType_Graphics, lLastUpdatedIgnored)
+    bool fIsGuestSupportsGraphics = guest().GetFacilityStatus(KAdditionsFacilityType_Graphics, lLastUpdatedIgnored)
                                     == KAdditionsFacilityStatus_Active;
-    bool fIsGuestSupportsSeamless = guest.GetFacilityStatus(KAdditionsFacilityType_Seamless, lLastUpdatedIgnored)
+    bool fIsGuestSupportsSeamless = guest().GetFacilityStatus(KAdditionsFacilityType_Seamless, lLastUpdatedIgnored)
                                     == KAdditionsFacilityStatus_Active;
     /* Check if something had changed: */
@@ -998,6 +966,36 @@
         return false;
 
+    /* Get machine: */
+    m_machine = m_session.GetMachine();
+    if (m_machine.isNull())
+        return false;
+
+    /* Get console: */
+    m_console = m_session.GetConsole();
+    if (m_console.isNull())
+        return false;
+
+    /* Get display: */
+    m_display = m_console.GetDisplay();
+    if (m_display.isNull())
+        return false;
+
+    /* Get mouse: */
+    m_mouse = m_console.GetMouse();
+    if (m_mouse.isNull())
+        return false;
+
+    /* Get guest: */
+    m_guest = m_console.GetGuest();
+    if (m_guest.isNull())
+        return false;
+
+    /* Get debugger: */
+    m_debugger = m_console.GetDebugger();
+    if (m_debugger.isNull())
+        return false;
+
     /* Update machine-state: */
-    m_machineState = m_session.GetMachine().GetState();
+    m_machineState = machine().GetState();
 
     /* True by default: */
@@ -1014,7 +1012,6 @@
         actionPool()->toRuntime()->setSession(this);
 
-        /* Get host/machine: */
+        /* Get host: */
         const CHost host = vboxGlobal().host();
-        const CMachine machine = session().GetConsole().GetMachine();
         UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restriction = UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid;
 
@@ -1024,5 +1021,5 @@
             int iDevicesCountCD = 0;
             int iDevicesCountFD = 0;
-            foreach (const CMediumAttachment &attachment, machine.GetMediumAttachments())
+            foreach (const CMediumAttachment &attachment, machine().GetMediumAttachments())
             {
                 if (attachment.GetType() == KDeviceType_DVD)
@@ -1045,9 +1042,9 @@
             /* Initialize Network menu: */
             bool fAtLeastOneAdapterActive = false;
-            const KChipsetType chipsetType = machine.GetChipsetType();
+            const KChipsetType chipsetType = machine().GetChipsetType();
             ULONG uSlots = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(chipsetType);
             for (ULONG uSlot = 0; uSlot < uSlots; ++uSlot)
             {
-                const CNetworkAdapter &adapter = machine.GetNetworkAdapter(uSlot);
+                const CNetworkAdapter &adapter = machine().GetNetworkAdapter(uSlot);
                 if (adapter.GetEnabled())
                 {
@@ -1063,7 +1060,7 @@
         {
             /* Check whether there is at least one USB controller with an available proxy. */
-            const bool fUSBEnabled =    !machine.GetUSBDeviceFilters().isNull()
-                                     && !machine.GetUSBControllers().isEmpty()
-                                     && machine.GetUSBProxyAvailable();
+            const bool fUSBEnabled =    !machine().GetUSBDeviceFilters().isNull()
+                                     && !machine().GetUSBControllers().isEmpty()
+                                     && machine().GetUSBProxyAvailable();
             if (!fUSBEnabled)
                 restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_USBDevices);
@@ -1074,5 +1071,5 @@
             /* Check whether there is an accessible video input devices pool: */
             host.GetVideoInputDevices();
-            const bool fWebCamsEnabled = host.isOk() && !machine.GetUSBControllers().isEmpty();
+            const bool fWebCamsEnabled = host.isOk() && !machine().GetUSBControllers().isEmpty();
             if (!fWebCamsEnabled)
                 restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_WebCams);
@@ -1189,9 +1186,6 @@
 #endif /* Q_WS_MAC */
 
-    /* Get machine: */
-    CMachine machine = m_session.GetMachine();
-
     /* Prepare initial screen visibility status: */
-    m_monitorVisibilityVector.resize(machine.GetMonitorCount());
+    m_monitorVisibilityVector.resize(machine().GetMonitorCount());
     m_monitorVisibilityVector.fill(false);
     m_monitorVisibilityVector[0] = true;
@@ -1205,5 +1199,5 @@
             BOOL fEnabled = true;
             ULONG guestOriginX = 0, guestOriginY = 0, guestWidth = 0, guestHeight = 0;
-            machine.QuerySavedGuestScreenInfo(i, guestOriginX, guestOriginY, guestWidth, guestHeight, fEnabled);
+            machine().QuerySavedGuestScreenInfo(i, guestOriginX, guestOriginY, guestWidth, guestHeight, fEnabled);
             m_monitorVisibilityVector[i] = fEnabled;
         }
@@ -1217,5 +1211,5 @@
 {
     /* Each framebuffer will be really prepared on first UIMachineView creation: */
-    m_frameBufferVector.resize(m_session.GetMachine().GetMonitorCount());
+    m_frameBufferVector.resize(machine().GetMonitorCount());
 }
 
@@ -1326,7 +1320,5 @@
             pFrameBuffer->setMarkAsUnused(true);
             /* Detach framebuffer from Display: */
-            CDisplay display = session().GetConsole().GetDisplay();
-            if (!display.isNull())
-                display.DetachFramebuffer(i);
+            display().DetachFramebuffer(i);
             /* Release framebuffer reference: */
             m_frameBufferVector[i].setNull();
@@ -1366,4 +1358,28 @@
 void UISession::cleanupSession()
 {
+    /* Detach debugger: */
+    if (!m_debugger.isNull())
+        m_debugger.detach();
+
+    /* Detach guest: */
+    if (!m_guest.isNull())
+        m_guest.detach();
+
+    /* Detach mouse: */
+    if (!m_mouse.isNull())
+        m_mouse.detach();
+
+    /* Detach display: */
+    if (!m_display.isNull())
+        m_display.detach();
+
+    /* Detach console: */
+    if (!m_console.isNull())
+        m_console.detach();
+
+    /* Detach machine: */
+    if (!m_machine.isNull())
+        m_machine.detach();
+
     /* Close session: */
     if (!m_session.isNull())
@@ -1663,16 +1679,14 @@
         popupCenter().remindAboutAutoCapture(machineLogic()->activeMachineWindow());
 
-    /* Shows First Run wizard if necessary: */
-    const CMachine &machine = session().GetMachine();
     /* Check if we are in teleportation waiting mode.
      * In that case no first run wizard is necessary. */
-    m_machineState = machine.GetState();
+    m_machineState = machine().GetState();
     if (   isFirstTimeStarted()
         && !((   m_machineState == KMachineState_PoweredOff
               || m_machineState == KMachineState_Aborted
               || m_machineState == KMachineState_Teleported)
-             && machine.GetTeleporterEnabled()))
-    {
-        UISafePointerWizard pWizard = new UIWizardFirstRun(mainMachineWindow(), session().GetMachine());
+             && machine().GetTeleporterEnabled()))
+    {
+        UISafePointerWizard pWizard = new UIWizardFirstRun(mainMachineWindow(), machine());
         pWizard->prepare();
         pWizard->exec();
@@ -1682,5 +1696,4 @@
 
 #ifdef VBOX_WITH_NETFLT
-
     /* Skip further checks if VM in saved state */
     if (isSaved())
@@ -1703,8 +1716,8 @@
     }
 
-    ulong cCount = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(machine.GetChipsetType());
+    ulong cCount = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(machine().GetChipsetType());
     for (ulong uAdapterIndex = 0; uAdapterIndex < cCount; ++uAdapterIndex)
     {
-        CNetworkAdapter na = machine.GetNetworkAdapter(uAdapterIndex);
+        CNetworkAdapter na = machine().GetNetworkAdapter(uAdapterIndex);
 
         if (na.GetEnabled())
@@ -1736,5 +1749,5 @@
     if (!failedInterfaceNames.isEmpty())
     {
-        if (msgCenter().UIMessageCenter::cannotStartWithoutNetworkIf(machine.GetName(), failedInterfaceNames.join(", ")))
+        if (msgCenter().UIMessageCenter::cannotStartWithoutNetworkIf(machineName(), failedInterfaceNames.join(", ")))
             machineLogic()->openNetworkSettingsDialog();
         else
@@ -1744,6 +1757,5 @@
         }
     }
-
-#endif
+#endif /* VBOX_WITH_NETFLT */
 
     return true;
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h	(revision 53013)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h	(revision 53028)
@@ -30,4 +30,10 @@
 #include "COMEnums.h"
 #include "CSession.h"
+#include "CMachine.h"
+#include "CConsole.h"
+#include "CDisplay.h"
+#include "CMouse.h"
+#include "CGuest.h"
+#include "CMachineDebugger.h"
 
 /* Forward declarations: */
@@ -89,6 +95,22 @@
     void closeRuntimeUI();
 
-    /* Common getters: */
+    /** Returns the session instance. */
     CSession& session() { return m_session; }
+    /** Returns the session's machine instance. */
+    CMachine& machine() { return m_machine; }
+    /** Returns the session's console instance. */
+    CConsole& console() { return m_console; }
+    /** Returns the console's display instance. */
+    CDisplay& display() { return m_display; }
+    /** Returns the console's mouse instance. */
+    CMouse& mouse() { return m_mouse; }
+    /** Returns the console's guest instance. */
+    CGuest& guest() { return m_guest; }
+    /** Returns the console's debugger instance. */
+    CMachineDebugger& debugger() { return m_debugger; }
+
+    /** Returns the machine name. */
+    const QString& machineName() const { return m_strMachineName; }
+
     UIActionPool* actionPool() const { return m_pActionPool; }
     KMachineState machineStatePrevious() const { return m_machineStatePrevious; }
@@ -357,4 +379,19 @@
     /** Holds the session instance. */
     CSession m_session;
+    /** Holds the session's machine instance. */
+    CMachine m_machine;
+    /** Holds the session's console instance. */
+    CConsole m_console;
+    /** Holds the console's display instance. */
+    CDisplay m_display;
+    /** Holds the console's mouse instance. */
+    CMouse m_mouse;
+    /** Holds the console's guest instance. */
+    CGuest m_guest;
+    /** Holds the console's debugger instance. */
+    CMachineDebugger m_debugger;
+
+    /** Holds the machine name. */
+    QString m_strMachineName;
 
     /** Holds the action-pool instance. */
