VirtualBox

Changeset 45224 in vbox for trunk/src


Ignore:
Timestamp:
Mar 28, 2013 10:12:52 AM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: Power-off sequence cleanup.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r45167 r45224  
    488488}
    489489
    490 void UIMachine::sltCloseVirtualMachine()
    491 {
    492     delete this;
    493 }
    494 
    495490void UIMachine::enterInitialVisualState()
    496491{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r44529 r45224  
    5555    void sltChangeVisualState(UIVisualStateType visualStateType);
    5656
    57     /* Close VM slot: */
    58     void sltCloseVirtualMachine();
    59 
    6057private:
    6158
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r45193 r45224  
    361361        case KMachineState_Aborted:
    362362        {
    363             /* Close VM if it was turned off and closure allowed: */
     363            /* Is it allowed to close Runtime UI? */
    364364            if (!isPreventAutoClose())
    365365            {
    366                 /* VM has been powered off, saved or aborted, no matter
    367                  * internally or externally. We must *safely* close VM window(s): */
    368                 QTimer::singleShot(0, uisession(), SLOT(sltCloseVirtualSession()));
     366                /* VM has been powered off, saved, teleported or aborted.
     367                 * We must close Runtime UI: */
     368                uisession()->closeRuntimeUI();
    369369            }
    370370            break;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r45213 r45224  
    251251    pEvent->ignore();
    252252
    253     /* Should we shutdown UI session? */
    254     bool fShutdownSession = false;
     253    /* Should we close Runtime UI? */
     254    bool fCloseRuntimeUI = false;
    255255
    256256    /* Make sure machine is in one of the allowed states: */
     
    320320                {
    321321                    fSuccess = uisession()->saveState();
    322                     fShutdownSession = fSuccess;
     322                    fCloseRuntimeUI = fSuccess;
    323323                    break;
    324324                }
     
    336336                    fSuccess = uisession()->powerOff(dialogResult == UIVMCloseDialog::ResultCode_PowerOff_With_Discarding,
    337337                                                     fServerCrashed);
    338                     fShutdownSession = fSuccess || fServerCrashed;
     338                    fCloseRuntimeUI = fSuccess || fServerCrashed;
    339339                    break;
    340340                }
     
    345345
    346346        /* Restore the running state if needed: */
    347         if (fSuccess && !fShutdownSession && !fWasPaused && uisession()->machineState() == KMachineState_Paused)
     347        if (fSuccess && !fCloseRuntimeUI && !fWasPaused && uisession()->machineState() == KMachineState_Paused)
    348348            uisession()->unpause();
    349349
     
    352352    }
    353353
    354     if (fShutdownSession)
    355     {
    356         /* VM has been powered off or saved. We must *safely* close VM window(s): */
    357         QTimer::singleShot(0, uisession(), SLOT(sltCloseVirtualSession()));
    358     }
     354    /* We've received a request to close Runtime UI: */
     355    if (fCloseRuntimeUI)
     356        uisession()->closeRuntimeUI();
    359357}
    360358
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r45213 r45224  
    2222#include <QDesktopWidget>
    2323#include <QWidget>
    24 #include <QTimer>
    2524
    2625/* GUI includes: */
     
    211210        if (vboxGlobal().showStartVMErrors())
    212211            msgCenter().cannotStartMachine(console);
    213         QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession()));
     212        closeRuntimeUI();
    214213        return;
    215214    }
     
    236235        if (vboxGlobal().showStartVMErrors())
    237236            msgCenter().cannotStartMachine(progress);
    238         QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession()));
     237        closeRuntimeUI();
    239238        return;
    240239    }
     
    247246    if (isTurnedOff())
    248247    {
    249         QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession()));
     248        closeRuntimeUI();
    250249        return;
    251250    }
     
    291290            else
    292291                msgCenter().cannotStopMachine(console);
    293             /* Now signal the destruction of the rest. */
    294             QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession()));
     292            closeRuntimeUI();
    295293            return;
    296294        }
     
    427425}
    428426
     427void UISession::closeRuntimeUI()
     428{
     429    /* Start corresponding slot asynchronously: */
     430    emit sigCloseRuntimeUI();
     431}
     432
    429433UIMachineLogic* UISession::machineLogic() const
    430434{
     
    601605}
    602606
    603 void UISession::sltCloseVirtualSession()
    604 {
    605     /* First, we have to close/hide any opened modal & popup application widgets.
    606      * We have to make sure such window is hidden even if close-event was rejected.
    607      * We are re-throwing this slot if any widget present to test again.
    608      * If all opened widgets are closed/hidden, we can try to close machine-window: */
    609     QWidget *pWidget = QApplication::activeModalWidget() ? QApplication::activeModalWidget() :
    610                        QApplication::activePopupWidget() ? QApplication::activePopupWidget() : 0;
    611     if (pWidget)
    612     {
    613         /* Closing/hiding all we found: */
     607void UISession::sltCloseRuntimeUI()
     608{
     609    /* First, we have to hide any opened modal/popup widgets.
     610     * They then should unlock their event-loops synchronously.
     611     * If all such loops are unlocked, we can close Runtime UI: */
     612    if (QWidget *pWidget = QApplication::activeModalWidget() ?
     613                          QApplication::activeModalWidget() :
     614                           QApplication::activePopupWidget() ?
     615                           QApplication::activePopupWidget() : 0)
     616    {
     617        /* First we should try to close this widget: */
    614618        pWidget->close();
     619        /* If widget rejected the 'close-event' we can
     620         * still hide it and hope it will behave correctly
     621         * and unlock his event-loop if any: */
    615622        if (!pWidget->isHidden())
    616623            pWidget->hide();
    617         QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession()));
     624        /* Restart this slot asynchronously: */
     625        emit sigCloseRuntimeUI();
    618626        return;
    619627    }
    620628
    621     /* Recursively close all the opened warnings... */
    622     if (msgCenter().isAnyWarningShown())
    623     {
    624         msgCenter().closeAllWarnings();
    625         QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession()));
    626         return;
    627     }
    628 
    629     /* Finally, ask for closing virtual machine: */
    630     QTimer::singleShot(0, m_pMachine, SLOT(sltCloseVirtualMachine()));
     629    /* Finally close the Runtime UI: */
     630    m_pMachine->deleteLater();
    631631}
    632632
     
    845845void UISession::prepareConnections()
    846846{
     847    connect(this, SIGNAL(sigCloseRuntimeUI()), this, SLOT(sltCloseRuntimeUI()));
     848
    847849    connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)),
    848850            this, SIGNAL(sigHostScreenCountChanged(int)));
     
    13661368        else
    13671369        {
    1368             QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession()));
     1370            closeRuntimeUI();
    13691371            return false;
    13701372        }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r45213 r45224  
    8787    virtual ~UISession();
    8888
    89     /* Common members: */
     89    /* API: Runtime UI stuff: */
    9090    void powerUp();
    9191    bool saveState();
    9292    bool shutDown();
    9393    bool powerOff(bool fIncludingDiscard, bool &fServerCrashed);
     94    void closeRuntimeUI();
    9495
    9596    /* Common getters: */
     
    167168
    168169signals:
     170
     171    /* Notifier: Close Runtime UI stuff: */
     172    void sigCloseRuntimeUI();
    169173
    170174    /* Console callback signals: */
     
    199203private slots:
    200204
    201     /* Close uisession handler: */
    202     void sltCloseVirtualSession();
     205    /* Handler: Close Runtime UI stuff: */
     206    void sltCloseRuntimeUI();
    203207
    204208    /* Console events slots */
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