VirtualBox

Changeset 90893 in vbox for trunk/src


Ignore:
Timestamp:
Aug 25, 2021 5:15:36 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10067: Move power-off stuff to the place where it belongs (UISession); Besides that, rename power-down to power-off for consistency.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r90795 r90893  
    25942594}
    25952595
    2596 bool UICommon::restoreCurrentSnapshot(const QUuid &uMachineId)
    2597 {
    2598     /* Prepare result: */
    2599     bool fResult = false;
    2600 
     2596void UICommon::restoreCurrentSnapshot(const QUuid &uMachineId)
     2597{
    26012598    /* Open a session to modify VM: */
    26022599    const bool fDirectSessionAvailable = (m_enmType == UIType_RuntimeUI) && isSeparateProcess();
     
    26542651                break;
    26552652            }
    2656 
    2657             /* Success: */
    2658             fResult = true;
    26592653        }
    26602654        while (0);
     
    26632657        comSession.UnlockMachine();
    26642658    }
    2665 
    2666     /* Return result: */
    2667     return fResult;
    26682659}
    26692660
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r90760 r90893  
    520520
    521521        /** Restores current snapshot for machine with certain @a uMachineId. */
    522         bool restoreCurrentSnapshot(const QUuid &uMachineId);
     522        void restoreCurrentSnapshot(const QUuid &uMachineId);
    523523    /** @} */
    524524
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r90728 r90893  
    10271027}
    10281028
    1029 void UIMessageCenter::cannotPowerDownMachine(const CConsole &comConsole) const
     1029void UIMessageCenter::cannotPowerOffMachine(const CConsole &comConsole) const
    10301030{
    10311031    error(0, MessageType_Error,
     
    10351035}
    10361036
    1037 void UIMessageCenter::cannotPowerDownMachine(const CProgress &comProgress, const QString &strMachineName) const
     1037void UIMessageCenter::cannotPowerOffMachine(const CProgress &comProgress, const QString &strMachineName) const
    10381038{
    10391039    error(0, MessageType_Error,
     
    26252625    if (fFatal)
    26262626    {
    2627         /* Power down after a fFatal error: */
    2628         LogRel(("GUI: Powering VM down after a fatal runtime error...\n"));
     2627        /* Power off after a fFatal error: */
     2628        LogRel(("GUI: Powering VM off after a fatal runtime error...\n"));
    26292629        console1.PowerDown();
    26302630    }
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r90728 r90893  
    310310    void cannotPowerUpCloudMachine(const CCloudMachine &comMachine) const;
    311311    void cannotPowerUpCloudMachine(const CProgress &comProgress, const QString &strMachineName) const;
    312     void cannotPowerDownMachine(const CConsole &comConsole) const;
    313     void cannotPowerDownMachine(const CProgress &comProgress, const QString &strMachineName) const;
     312    void cannotPowerOffMachine(const CConsole &comConsole) const;
     313    void cannotPowerOffMachine(const CProgress &comProgress, const QString &strMachineName) const;
    314314    void cannotPowerDownCloudMachine(const CCloudMachine &comMachine) const;
    315315    void cannotPowerDownCloudMachine(const CProgress &comProgress, const QString &strMachineName) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r90869 r90893  
    18191819        if (pItem->itemType() == UIVirtualMachineItemType_Local)
    18201820        {
    1821             /* Powering VM down: */
    1822             UINotificationProgressMachinePowerDown *pNotification =
    1823                 new UINotificationProgressMachinePowerDown(pItem->toLocal()->machine());
     1821            /* Powering VM off: */
     1822            UINotificationProgressMachinePowerOff *pNotification =
     1823                new UINotificationProgressMachinePowerOff(pItem->toLocal()->machine());
    18241824            gpNotificationCenter->append(pNotification);
    18251825        }
     
    18271827        else if (pItem->itemType() == UIVirtualMachineItemType_CloudReal)
    18281828        {
    1829             /* Powering cloud VM down: */
    1830             UINotificationProgressCloudMachinePowerDown *pNotification =
    1831                 new UINotificationProgressCloudMachinePowerDown(pItem->toCloud()->machine());
     1829            /* Powering cloud VM off: */
     1830            UINotificationProgressCloudMachinePowerOff *pNotification =
     1831                new UINotificationProgressCloudMachinePowerOff(pItem->toCloud()->machine());
    18321832            gpNotificationCenter->append(pNotification);
    18331833        }
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r90869 r90893  
    973973
    974974/*********************************************************************************************************************************
    975 *   Class UINotificationProgressMachinePowerDown implementation.                                                                 *
    976 *********************************************************************************************************************************/
    977 
    978 UINotificationProgressMachinePowerDown::UINotificationProgressMachinePowerDown(const CMachine &comMachine)
     975*   Class UINotificationProgressMachinePowerOff implementation.                                                                  *
     976*********************************************************************************************************************************/
     977
     978UINotificationProgressMachinePowerOff::UINotificationProgressMachinePowerOff(const CMachine &comMachine)
    979979    : m_comMachine(comMachine)
    980980{
    981981    connect(this, &UINotificationProgress::sigProgressFinished,
    982             this, &UINotificationProgressMachinePowerDown::sltHandleProgressFinished);
    983 }
    984 
    985 UINotificationProgressMachinePowerDown::UINotificationProgressMachinePowerDown(const CConsole &comConsole)
     982            this, &UINotificationProgressMachinePowerOff::sltHandleProgressFinished);
     983}
     984
     985UINotificationProgressMachinePowerOff::UINotificationProgressMachinePowerOff(const CConsole &comConsole)
    986986    : m_comConsole(comConsole)
    987987{
    988988    connect(this, &UINotificationProgress::sigProgressFinished,
    989             this, &UINotificationProgressMachinePowerDown::sltHandleProgressFinished);
    990 }
    991 
    992 QString UINotificationProgressMachinePowerDown::name() const
    993 {
    994     return UINotificationProgress::tr("Powering VM down ...");
    995 }
    996 
    997 QString UINotificationProgressMachinePowerDown::details() const
     989            this, &UINotificationProgressMachinePowerOff::sltHandleProgressFinished);
     990}
     991
     992QString UINotificationProgressMachinePowerOff::name() const
     993{
     994    return UINotificationProgress::tr("Powering VM off ...");
     995}
     996
     997QString UINotificationProgressMachinePowerOff::details() const
    998998{
    999999    return UINotificationProgress::tr("<b>VM Name:</b> %1").arg(m_strName);
    10001000}
    10011001
    1002 CProgress UINotificationProgressMachinePowerDown::createProgress(COMResult &comResult)
     1002CProgress UINotificationProgressMachinePowerOff::createProgress(COMResult &comResult)
    10031003{
    10041004    /* Prepare machine to power off: */
     
    10861086}
    10871087
    1088 void UINotificationProgressMachinePowerDown::sltHandleProgressFinished()
     1088void UINotificationProgressMachinePowerOff::sltHandleProgressFinished()
    10891089{
    10901090    /* Unlock session finally: */
     
    13371337
    13381338/*********************************************************************************************************************************
    1339 *   Class UINotificationProgressCloudMachinePowerDown implementation.                                                            *
    1340 *********************************************************************************************************************************/
    1341 
    1342 UINotificationProgressCloudMachinePowerDown::UINotificationProgressCloudMachinePowerDown(const CCloudMachine &comMachine)
     1339*   Class UINotificationProgressCloudMachinePowerOff implementation.                                                             *
     1340*********************************************************************************************************************************/
     1341
     1342UINotificationProgressCloudMachinePowerOff::UINotificationProgressCloudMachinePowerOff(const CCloudMachine &comMachine)
    13431343    : m_comMachine(comMachine)
    13441344{
    13451345}
    13461346
    1347 QString UINotificationProgressCloudMachinePowerDown::name() const
    1348 {
    1349     return   UINotificationProgress::tr("Powering cloud VM down ...");
    1350 }
    1351 
    1352 QString UINotificationProgressCloudMachinePowerDown::details() const
     1347QString UINotificationProgressCloudMachinePowerOff::name() const
     1348{
     1349    return   UINotificationProgress::tr("Powering cloud VM off ...");
     1350}
     1351
     1352QString UINotificationProgressCloudMachinePowerOff::details() const
    13531353{
    13541354    return UINotificationProgress::tr("<b>VM Name:</b> %1").arg(m_strName);
    13551355}
    13561356
    1357 CProgress UINotificationProgressCloudMachinePowerDown::createProgress(COMResult &comResult)
     1357CProgress UINotificationProgressCloudMachinePowerOff::createProgress(COMResult &comResult)
    13581358{
    13591359    /* Acquire cloud VM name: */
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r90869 r90893  
    559559};
    560560
    561 /** UINotificationProgress extension for machine power-down functionality. */
    562 class SHARED_LIBRARY_STUFF UINotificationProgressMachinePowerDown : public UINotificationProgress
    563 {
    564     Q_OBJECT;
    565 
    566 public:
    567 
    568     /** Constructs machine power-down notification-progress.
     561/** UINotificationProgress extension for machine power-off functionality. */
     562class SHARED_LIBRARY_STUFF UINotificationProgressMachinePowerOff : public UINotificationProgress
     563{
     564    Q_OBJECT;
     565
     566public:
     567
     568    /** Constructs machine power-off notification-progress.
    569569      * @param  comMachine  Brings the machine being powered off. */
    570     UINotificationProgressMachinePowerDown(const CMachine &comMachine);
    571     /** Constructs machine power-down notification-progress.
     570    UINotificationProgressMachinePowerOff(const CMachine &comMachine);
     571    /** Constructs machine power-off notification-progress.
    572572      * @param  comConsole  Brings the console of machine being powered off. */
    573     UINotificationProgressMachinePowerDown(const CConsole &comConsole);
     573    UINotificationProgressMachinePowerOff(const CConsole &comConsole);
    574574
    575575protected:
     
    826826};
    827827
    828 /** UINotificationProgress extension for cloud machine power-down functionality. */
    829 class SHARED_LIBRARY_STUFF UINotificationProgressCloudMachinePowerDown : public UINotificationProgress
    830 {
    831     Q_OBJECT;
    832 
    833 public:
    834 
    835     /** Constructs cloud machine power-down notification-progress.
    836       * @param  comMachine  Brings the machine being powered-down. */
    837     UINotificationProgressCloudMachinePowerDown(const CCloudMachine &comMachine);
    838 
    839 protected:
    840 
    841     /** Returns object name. */
    842     virtual QString name() const /* override final */;
    843     /** Returns object details. */
    844     virtual QString details() const /* override final */;
    845     /** Creates and returns started progress-wrapper. */
    846     virtual CProgress createProgress(COMResult &comResult) /* override final */;
    847 
    848 private:
    849 
    850     /** Holds the machine being powered-down. */
     828/** UINotificationProgress extension for cloud machine power-off functionality. */
     829class SHARED_LIBRARY_STUFF UINotificationProgressCloudMachinePowerOff : public UINotificationProgress
     830{
     831    Q_OBJECT;
     832
     833public:
     834
     835    /** Constructs cloud machine power-off notification-progress.
     836      * @param  comMachine  Brings the machine being powered-off. */
     837    UINotificationProgressCloudMachinePowerOff(const CCloudMachine &comMachine);
     838
     839protected:
     840
     841    /** Returns object name. */
     842    virtual QString name() const /* override final */;
     843    /** Returns object details. */
     844    virtual QString details() const /* override final */;
     845    /** Creates and returns started progress-wrapper. */
     846    virtual CProgress createProgress(COMResult &comResult) /* override final */;
     847
     848private:
     849
     850    /** Holds the machine being powered-off. */
    851851    CCloudMachine  m_comMachine;
    852852    /** Holds the machine name. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r90890 r90893  
    386386#endif /* VBOX_WS_MAC */
    387387
    388 void UIMachineLogic::powerOff(bool fDiscardingState)
    389 {
    390     /* Enable 'manual-override',
    391      * preventing automatic Runtime UI closing: */
    392     uisession()->setManualOverrideMode(true);
    393 
    394     /* Was the step successful? */
    395     bool fSuccess = true;
    396     /* Power-off: */
    397     bool fServerCrashed = false;
    398     LogRel(("GUI: Passing request to power VM off from machine-logic to UI session.\n"));
    399     fSuccess = uisession()->powerOff(fDiscardingState, fServerCrashed) || fServerCrashed;
    400 
    401     /* Disable 'manual-override' finally: */
    402     uisession()->setManualOverrideMode(false);
    403 
    404     /* Manually close Runtime UI: */
    405     if (fSuccess)
    406         uisession()->closeRuntimeUI();
    407 }
    408 
    409388void UIMachineLogic::notifyAbout3DOverlayVisibilityChange(bool fVisible)
    410389{
     
    433412    /* Power VM off: */
    434413    LogRel(("GUI: Request to power VM off due to VBoxSVC is unavailable.\n"));
    435     powerOff(false /* do NOT restore current snapshot */);
     414    uisession()->powerOff(false /* do NOT restore current snapshot */);
    436415}
    437416
     
    488467                    if (msgCenter().remindAboutGuruMeditation(QDir::toNativeSeparators(strLogFolder)))
    489468                    {
    490                         LogRel(("GUI: User request to power VM off on Guru Meditation.\n"));
    491                         powerOff(false /* do NOT restore current snapshot */);
     469                        LogRel(("GUI: User requested to power VM off on Guru Meditation.\n"));
     470                        uisession()->powerOff(false /* do NOT restore current snapshot */);
    492471                    }
    493472                    break;
     
    497476                {
    498477                    LogRel(("GUI: Automatic request to power VM off on Guru Meditation.\n"));
    499                     powerOff(false /* do NOT restore current snapshot */);
     478                    uisession()->powerOff(false /* do NOT restore current snapshot */);
    500479                    break;
    501480                }
     
    18851864    LogRel(("GUI: User requested to power VM off.\n"));
    18861865    const bool fDiscardStateOnPowerOff = gEDataManager->discardStateOnPowerOff(uiCommon().managedVMUuid());
    1887     powerOff(machine().GetSnapshotCount() > 0 && fDiscardStateOnPowerOff);
     1866    uisession()->powerOff(machine().GetSnapshotCount() > 0 && fDiscardStateOnPowerOff);
    18881867}
    18891868
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r90890 r90893  
    142142    virtual void updateDock();
    143143#endif /* VBOX_WS_MAC */
    144 
    145     /** Power off VM, then close Runtime UI. */
    146     void powerOff(bool fDiscardingState);
    147144
    148145    /* API: 3D overlay visibility stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r90890 r90893  
    470470            LogRel(("GUI: Request for close-action to power VM off.\n"));
    471471            const bool fDiscardStateOnPowerOff = gEDataManager->discardStateOnPowerOff(uiCommon().managedVMUuid());
    472             machineLogic()->powerOff(machine().GetSnapshotCount() > 0 && fDiscardStateOnPowerOff);
     472            uisession()->powerOff(machine().GetSnapshotCount() > 0 && fDiscardStateOnPowerOff);
    473473            break;
    474474        }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r90890 r90893  
    369369}
    370370
    371 bool UISession::powerOff(bool fIncludingDiscard, bool &fServerCrashed)
    372 {
     371void UISession::powerOff(bool fIncludingDiscard)
     372{
     373    /* Prepare result: */
     374    bool fSuccess = false;
     375
     376    /* Enable 'manual-override',
     377     * preventing automatic Runtime UI closing: */
     378    setManualOverrideMode(true);
     379
    373380    /* Prepare the power-off progress: */
    374     LogRel(("GUI: Powering VM down on UI session power off request...\n"));
    375     CProgress progress = console().PowerDown();
    376     if (console().isOk())
     381    LogRel(("GUI: Powering VM off..\n"));
     382    CProgress comProgress = console().PowerDown();
     383    if (!console().isOk())
     384    {
     385        /* Check the console state, it might be already gone: */
     386        if (!console().isNull())
     387        {
     388            /* This can happen if VBoxSVC is not running: */
     389            COMResult res(console());
     390            if (FAILED_DEAD_INTERFACE(res.rc()))
     391               fSuccess = true;
     392        }
     393
     394        if (!fSuccess)
     395            msgCenter().cannotPowerOffMachine(console());
     396    }
     397    else
    377398    {
    378399        /* Show the power-off progress: */
    379         msgCenter().showModalProgressDialog(progress, machineName(), ":/progress_poweroff_90px.png");
    380         if (progress.isOk() && progress.GetResultCode() == 0)
    381         {
     400        msgCenter().showModalProgressDialog(comProgress, machineName(), ":/progress_poweroff_90px.png");
     401        if (comProgress.isOk() && comProgress.GetResultCode() == 0)
     402        {
     403            fSuccess = true;
     404
    382405            /* Discard the current state if requested: */
    383406            if (fIncludingDiscard)
    384                 return uiCommon().restoreCurrentSnapshot(uiCommon().managedVMUuid());
     407                uiCommon().restoreCurrentSnapshot(uiCommon().managedVMUuid());
    385408        }
    386409        else
    387         {
    388             /* Failed in progress: */
    389             msgCenter().cannotPowerDownMachine(progress, machineName());
    390             return false;
    391         }
    392     }
    393     else
    394     {
    395         /* Check the machine state, it might be already gone: */
    396         if (!console().isNull())
    397         {
    398            /* Failed in console: */
    399            COMResult res(console());
    400            /* This can happen if VBoxSVC is not running: */
    401            if (FAILED_DEAD_INTERFACE(res.rc()))
    402                fServerCrashed = true;
    403            else
    404                msgCenter().cannotPowerDownMachine(console());
    405            return false;
    406         }
    407     }
    408     /* Passed: */
    409     return true;
     410            msgCenter().cannotPowerOffMachine(comProgress, machineName());
     411    }
     412
     413    /* Disable 'manual-override' finally: */
     414    setManualOverrideMode(false);
     415
     416    /* Manually close Runtime UI: */
     417    if (fSuccess)
     418        closeRuntimeUI();
    410419}
    411420
     
    19601969            setManualOverrideMode(true);
    19611970            /* Power off VM: */
    1962             bool fServerCrashed = false;
    19631971            LogRel(("GUI: Aborting startup due to postprocess initialization issue detected...\n"));
    1964             powerOff(false /* do NOT restore current snapshot */, fServerCrashed);
     1972            powerOff(false /* do NOT restore current snapshot */);
    19651973            return false;
    19661974        }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r90890 r90893  
    8383    /** Calls for guest shutdown to close Runtime UI. */
    8484    void shutdown();
    85     /** Powers VM down, then closes Runtime UI. */
    86     bool powerOff(bool fIncludingDiscard, bool &fServerCrashed);
     85    /** Powers VM off, then closes Runtime UI. */
     86    void powerOff(bool fIncludingDiscard);
    8787
    8888    /** Returns the session instance. */
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