VirtualBox

Changeset 86215 in vbox


Ignore:
Timestamp:
Sep 22, 2020 10:40:19 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: UIVirtualMachineItemCloud: Rework refresh timer to be more controllable.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.cpp

    r86208 r86215  
    4040    , m_enmMachineState(KCloudMachineState_Invalid)
    4141    , m_enmFakeCloudItemState(enmState)
    42 {
    43     recache();
     42    , m_pTimer(0)
     43{
     44    prepare();
    4445}
    4546
     
    4950    , m_enmMachineState(KCloudMachineState_Invalid)
    5051    , m_enmFakeCloudItemState(UIFakeCloudVirtualMachineItemState_NotApplicable)
    51 {
    52     recache();
     52    , m_pTimer(0)
     53{
     54    prepare();
    5355}
    5456
     
    7173void UIVirtualMachineItemCloud::updateInfoAsync(bool fDelayed)
    7274{
    73     QTimer::singleShot(fDelayed ? 10000 : 0, this, SLOT(sltRefreshCloudMachineInfo()));
     75    /* Ignore refresh request if timer or progress is already running: */
     76    if (m_pTimer->isActive() || m_pProgressHandler)
     77        return;
     78
     79    /* Schedule refresh request in a 10 or 0 seconds: */
     80    m_pTimer->setInterval(fDelayed ? 10000 : 0);
     81    m_pTimer->start();
    7482}
    7583
     
    305313void UIVirtualMachineItemCloud::sltHandleRefreshCloudMachineInfoDone()
    306314{
     315    /* Was the progress canceled? */
     316    const bool fCanceled = m_comProgress.GetCanceled();
     317
    307318    /* If not canceled => check progress result: */
    308     if (   !m_comProgress.GetCanceled()
    309         && (!m_comProgress.isOk() || m_comProgress.GetResultCode() != 0))
    310             msgCenter().cannotAcquireCloudMachineParameter(m_comProgress);
     319    if (!fCanceled && (!m_comProgress.isOk() || m_comProgress.GetResultCode() != 0))
     320        msgCenter().cannotAcquireCloudMachineParameter(m_comProgress);
    311321
    312322    /* Recache: */
    313323    recache();
    314324
    315     /* If not canceled => notify listeners: */
    316     if (!m_comProgress.GetCanceled())
    317         emit sigStateChange();
    318 
    319325    /* Cleanup the handler and the progress: */
    320326    delete m_pProgressHandler;
    321     m_pProgressHandler = 0;
    322327    m_comProgress = CProgress();
    323 }
     328
     329    /* If not canceled => notify listeners: */
     330    if (!fCanceled)
     331        emit sigStateChange();
     332}
     333
     334void UIVirtualMachineItemCloud::prepare()
     335{
     336    /* Prepare timer: */
     337    m_pTimer = new QTimer(this);
     338    if (m_pTimer)
     339    {
     340        m_pTimer->setSingleShot(true);
     341        connect(m_pTimer, &QTimer::timeout,
     342                this, &UIVirtualMachineItemCloud::sltRefreshCloudMachineInfo);
     343    }
     344
     345    /* Recache finally: */
     346    recache();
     347}
     348
     349void UIVirtualMachineItemCloud::cleanup()
     350{
     351    /* Cleanup timer: */
     352    delete m_pTimer;
     353    m_pTimer = 0;
     354}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.h

    r86207 r86215  
    3434
    3535/* Forward declarations: */
     36class QTimer;
    3637class UIProgress;
    3738
     
    133134private:
    134135
     136    /** @name Prepare/Cleanup cascade.
     137      * @{ */
     138        /** Prepares all. */
     139        void prepare();
     140        /** Cleanups all. */
     141        void cleanup();
     142    /** @} */
     143
    135144    /** @name Arguments.
    136145      * @{ */
     
    149158        QString                             m_strFakeCloudItemErrorMessage;
    150159
     160        /** Holds the machine refresh timer instance. */
     161        QTimer               *m_pTimer;
    151162        /** Holds the machine refresh progress object instance. */
    152163        CProgress             m_comProgress;
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