VirtualBox

Changeset 98402 in vbox for trunk


Ignore:
Timestamp:
Feb 1, 2023 2:58:03 PM (2 years ago)
Author:
vboxsync
Message:

Merging r155437 and r155438 from gui4 branch: FE/Qt: Runtime UI: A bit of cleanup for UISession close stuff; Tiny cleanup for UIMachine factory and close stuff.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:mergeinfo
      •  

        old new  
        1919/branches/dsen/gui2:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644
        2020/branches/dsen/gui3:79645-79692
        21 /branches/dsen/gui4:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311,155316,155336,155342,155344
         21/branches/dsen/gui4:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311,155316,155336,155342,155344,155437-155438
        2222/trunk/src:92342,154921
  • trunk/src/VBox

    • Property svn:mergeinfo
      •  

        old new  
        1919/branches/dsen/gui2/src/VBox:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644
        2020/branches/dsen/gui3/src/VBox:79645-79692
        21 /branches/dsen/gui4/src/VBox:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311,155316,155336,155342,155344
         21/branches/dsen/gui4/src/VBox:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311,155316,155336,155342,155344,155437-155438
  • trunk/src/VBox/Frontends

    • Property svn:mergeinfo
      •  

        old new  
        1616/branches/dsen/gui2/src/VBox/Frontends:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644
        1717/branches/dsen/gui3/src/VBox/Frontends:79645-79692
        18 /branches/dsen/gui4/src/VBox/Frontends:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311,155316,155336,155342,155344
         18/branches/dsen/gui4/src/VBox/Frontends:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311,155316,155336,155342,155344,155437-155438
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r98401 r98402  
    108108
    109109/* static */
    110 UIMachine *UIMachine::m_spInstance = 0;
     110UIMachine *UIMachine::s_pInstance = 0;
    111111
    112112/* static */
     
    114114{
    115115    /* Make sure machine is not created: */
    116     AssertReturn(!m_spInstance, false);
     116    AssertReturn(!s_pInstance, false);
    117117
    118118    /* Restore current snapshot if requested: */
     
    166166{
    167167    /* Make sure machine is not created: */
    168     AssertReturn(!m_spInstance, false);
     168    AssertReturn(!s_pInstance, false);
    169169
    170170    /* Create machine UI: */
    171171    new UIMachine;
    172172    /* Make sure it's prepared: */
    173     if (!m_spInstance->prepare())
     173    if (!s_pInstance->prepare())
    174174    {
    175175        /* Destroy machine UI otherwise: */
     
    186186{
    187187    /* Make sure machine is created: */
    188     if (!m_spInstance)
     188    if (!s_pInstance)
    189189        return;
    190190
    191191    /* Protect versus recursive call: */
    192     UIMachine *pInstance = m_spInstance;
    193     m_spInstance = 0;
     192    UIMachine *pInstance = s_pInstance;
     193    s_pInstance = 0;
    194194    /* Cleanup machine UI: */
    195195    pInstance->cleanup();
     
    371371{
    372372    /* Create new machine-logic: */
    373     UIMachineLogic *pMachineLogic = UIMachineLogic::create(this, m_pSession, visualState);
     373    UIMachineLogic *pMachineLogic = UIMachineLogic::create(this, uisession(), visualState);
    374374
    375375    /* First we have to check if the selected machine-logic is available at all.
     
    714714    , m_restrictedCloseActions(MachineCloseAction_Invalid)
    715715{
    716     m_spInstance = this;
     716    s_pInstance = this;
    717717}
    718718
    719719UIMachine::~UIMachine()
    720720{
    721     m_spInstance = 0;
     721    s_pInstance = 0;
    722722}
    723723
     
    727727    if (!UISession::create(m_pSession, this))
    728728        return false;
    729     AssertPtrReturn(m_pSession, false);
     729    AssertPtrReturn(uisession(), false);
    730730
    731731    /* Cache media data early if necessary: */
    732732    if (uiCommon().agressiveCaching())
    733         uiCommon().enumerateMedia(m_pSession->machineMedia());
     733        uiCommon().enumerateMedia(uisession()->machineMedia());
    734734
    735735    /* Prepare stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98401 r98402  
    152152    static void destroy();
    153153    /** Static instance. */
    154     static UIMachine* instance() { return m_spInstance; }
     154    static UIMachine *instance() { return s_pInstance; }
    155155
    156156    /** Returns session UI instance. */
     
    296296    /** @} */
    297297
    298     /** @name Close configuration stuff.
     298    /** @name Close stuff.
    299299     * @{ */
    300300        /** Returns default close action. */
     
    318318    /** @} */
    319319
    320     /** Closes Runtime UI. */
    321     void closeRuntimeUI();
     320    /** @name Close stuff.
     321     * @{ */
     322        /** Closes Runtime UI. */
     323        void closeRuntimeUI();
     324    /** @} */
    322325
    323326private slots:
     
    499502    /** @} */
    500503
    501     /** Static instance. */
    502     static UIMachine* m_spInstance;
     504    /** Holds the static instance. */
     505    static UIMachine *s_pInstance;
    503506
    504507    /** Holds the session UI instance. */
     
    624627    /** @} */
    625628
    626     /** @name Close configuration stuff.
     629    /** @name Close stuff.
    627630     * @{ */
    628631        /** Default close action. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98401 r98402  
    249249void UISession::detachUi()
    250250{
     251    /* Manually close Runtime UI: */
     252    LogRel(("GUI: Detaching UI..\n"));
     253    closeRuntimeUI();
     254}
     255
     256void UISession::saveState()
     257{
     258    /* Prepare VM to be saved: */
     259    if (!prepareToBeSaved())
     260        return;
     261
    251262    /* Enable 'manual-override',
    252263     * preventing automatic Runtime UI closing: */
    253264    setManualOverrideMode(true);
    254265
    255     /* Manually close Runtime UI: */
    256     LogRel(("GUI: Detaching UI..\n"));
    257     closeRuntimeUI();
    258 }
    259 
    260 void UISession::saveState()
    261 {
    262     /* Saving state? */
    263     bool fSaveState = true;
    264 
    265     /* If VM is not paused, we should pause it first: */
    266     if (!isPaused())
    267         fSaveState = pause();
    268 
    269     /* Save state: */
    270     if (fSaveState)
    271     {
    272         /* Enable 'manual-override',
    273          * preventing automatic Runtime UI closing: */
    274         setManualOverrideMode(true);
    275 
    276         /* Now, do the magic: */
    277         LogRel(("GUI: Saving VM state..\n"));
    278         UINotificationProgressMachineSaveState *pNotification = new UINotificationProgressMachineSaveState(machine());
    279         connect(pNotification, &UINotificationProgressMachineSaveState::sigMachineStateSaved,
    280                 this, &UISession::sltHandleMachineStateSaved);
    281         gpNotificationCenter->append(pNotification);
    282     }
     266    /* Now, do the magic: */
     267    LogRel(("GUI: Saving VM state..\n"));
     268    UINotificationProgressMachineSaveState *pNotification =
     269        new UINotificationProgressMachineSaveState(machine());
     270    connect(pNotification, &UINotificationProgressMachineSaveState::sigMachineStateSaved,
     271            this, &UISession::sltHandleMachineStateSaved);
     272    gpNotificationCenter->append(pNotification);
    283273}
    284274
    285275void UISession::shutdown()
    286276{
    287     /* Warn the user about ACPI is not available if so: */
    288     if (!console().GetGuestEnteredACPIMode())
    289         return UINotificationMessage::cannotSendACPIToMachine();
    290 
    291     /* Send ACPI shutdown signal if possible: */
     277    /* Prepare VM to be shutdowned: */
     278    if (!prepareToBeShutdowned())
     279        return;
     280
     281    /* Now, do the magic: */
    292282    LogRel(("GUI: Sending ACPI shutdown signal..\n"));
    293     console().PowerButton();
    294     if (!console().isOk())
     283    CConsole comConsole = console();
     284    comConsole.PowerButton();
     285    if (!comConsole.isOk())
    295286        UINotificationMessage::cannotACPIShutdownMachine(console());
    296287}
     
    305296    LogRel(("GUI: Powering VM off..\n"));
    306297    UINotificationProgressMachinePowerOff *pNotification =
    307         new UINotificationProgressMachinePowerOff(machine(), console(), fIncludingDiscard);
     298        new UINotificationProgressMachinePowerOff(machine(),
     299                                                  console(),
     300                                                  fIncludingDiscard);
    308301    connect(pNotification, &UINotificationProgressMachinePowerOff::sigMachinePoweredOff,
    309302            this, &UISession::sltHandleMachinePoweredOff);
     
    333326bool UISession::isVisualStateAllowed(UIVisualStateType state) const
    334327{
    335     return m_pMachine->isVisualStateAllowed(state);
     328    return uimachine()->isVisualStateAllowed(state);
    336329}
    337330
    338331void UISession::changeVisualState(UIVisualStateType visualStateType)
    339332{
    340     m_pMachine->asyncChangeVisualState(visualStateType);
     333    uimachine()->asyncChangeVisualState(visualStateType);
    341334}
    342335
    343336void UISession::setRequestedVisualState(UIVisualStateType visualStateType)
    344337{
    345     m_pMachine->setRequestedVisualState(visualStateType);
     338    uimachine()->setRequestedVisualState(visualStateType);
    346339}
    347340
    348341UIVisualStateType UISession::requestedVisualState() const
    349342{
    350     return m_pMachine->requestedVisualState();
     343    return uimachine()->requestedVisualState();
    351344}
    352345
     
    998991}
    999992
     993bool UISession::prepareToBeSaved()
     994{
     995    return    isPaused()
     996           || (isRunning() && pause());
     997}
     998
     999bool UISession::prepareToBeShutdowned()
     1000{
     1001    const bool fValidMode = console().GetGuestEnteredACPIMode();
     1002    if (!fValidMode)
     1003        UINotificationMessage::cannotSendACPIToMachine();
     1004    return fValidMode;
     1005}
     1006
    10001007void UISession::loadVMSettings()
    10011008{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98401 r98402  
    266266    CMediumVector machineMedia() const;
    267267
     268    /** Prepares VM to be saved. */
     269    bool prepareToBeSaved();
     270    /** Returns whether VM can be shutdowned. */
     271    bool prepareToBeShutdowned();
     272
    268273public slots:
    269274
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette