VirtualBox

Ignore:
Timestamp:
Jan 11, 2024 12:12:42 PM (11 months ago)
Author:
vboxsync
Message:

FE/Qt: Chooser pane: A bit of cleanup for cloud VM update processing; More careful manual control over the repeated update scheduling.

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

Legend:

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

    r101382 r102836  
    114114    , m_enmMachineState(KCloudMachineState_Invalid)
    115115    , m_enmFakeCloudItemState(enmState)
    116     , m_fRefreshScheduled(false)
     116    , m_fUpdateRequiredByLocalReason(false)
    117117    , m_pProgressTaskRefresh(0)
    118118{
     
    125125    , m_enmMachineState(KCloudMachineState_Invalid)
    126126    , m_enmFakeCloudItemState(UIFakeCloudVirtualMachineItemState_NotApplicable)
    127     , m_fRefreshScheduled(false)
     127    , m_fUpdateRequiredByLocalReason(false)
    128128    , m_pProgressTaskRefresh(0)
    129129{
     
    148148}
    149149
    150 void UIVirtualMachineItemCloud::updateInfoAsync(bool fDelayed, bool fSubscribe /* = false */)
     150void UIVirtualMachineItemCloud::setUpdateRequiredByLocalReason(bool fRequired)
     151{
     152    m_fUpdateRequiredByLocalReason = fRequired;
     153}
     154
     155void UIVirtualMachineItemCloud::updateInfoAsync(bool fDelayed)
    151156{
    152157    /* Ignore refresh request if progress-task is absent: */
    153158    if (!m_pProgressTaskRefresh)
    154159        return;
    155 
    156     /* Mark update scheduled if requested: */
    157     if (fSubscribe)
    158         m_fRefreshScheduled = true;
    159160
    160161    /* Schedule refresh request in a 10 or 0 seconds
     
    165166}
    166167
    167 void UIVirtualMachineItemCloud::stopAsyncUpdates()
     168void UIVirtualMachineItemCloud::waitForAsyncInfoUpdateFinished()
    168169{
    169170    /* Ignore cancel request if progress-task is absent: */
     
    172173
    173174    /* Mark update canceled in any case: */
    174     m_fRefreshScheduled = false;
    175 }
    176 
    177 void UIVirtualMachineItemCloud::waitForAsyncInfoUpdateFinished()
    178 {
    179     /* Ignore cancel request if progress-task is absent: */
    180     if (!m_pProgressTaskRefresh)
    181         return;
    182 
    183     /* Mark update canceled in any case: */
    184     m_fRefreshScheduled = false;
     175    m_fUpdateRequiredByLocalReason = false;
    185176
    186177    /* Cancel refresh request
     
    400391    emit sigRefreshFinished();
    401392
    402     /* Refresh again if scheduled: */
    403     if (m_fRefreshScheduled)
    404         updateInfoAsync(true /* async? */);
     393    /* Refresh again if required: */
     394    if (m_fUpdateRequiredByLocalReason)
     395        updateInfoAsync(true /* delayed? */);
    405396}
    406397
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.h

    r98103 r102836  
    8484        QString fakeCloudItemErrorMessage() const { return m_strFakeCloudItemErrorMessage; }
    8585
    86         /** Updates cloud VM info async way, @a fDelayed if requested or instant otherwise.
    87           * @param  fSubscribe  Brings whether this update should be performed periodically. */
    88         void updateInfoAsync(bool fDelayed, bool fSubscribe = false);
    89         /** Stop periodical updates previously requested. */
    90         void stopAsyncUpdates();
     86        /** Defines whether update is @a fRequired by local reason. */
     87        void setUpdateRequiredByLocalReason(bool fRequired);
     88        /** Updates cloud VM info async way, @a fDelayed if requested or instantly otherwise. */
     89        void updateInfoAsync(bool fDelayed);
    9190        /** Makes sure async info update is finished.
    9291          * @note  This method creates own event-loop to avoid blocking calling thread event processing,
     
    166165        QString                             m_strFakeCloudItemErrorMessage;
    167166
    168         /** Holds whether we plan to refresh info. */
    169         bool            m_fRefreshScheduled;
     167        /** Holds whether update is required by local reason. */
     168        bool            m_fUpdateRequiredByLocalReason;
    170169        /** Holds the refresh progress-task instance. */
    171170        UIProgressTask *m_pProgressTaskRefresh;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp

    r101571 r102836  
    16471647    {
    16481648        AssertReturnVoid(pNode && pNode->cacheType() == UIVirtualMachineItemType_CloudReal);
    1649         pNode->cache()->toCloud()->updateInfoAsync(false /* delayed? */);
     1649        UIVirtualMachineItemCloud *pCloudMachineItem = pNode->cache()->toCloud();
     1650        pCloudMachineItem->updateInfoAsync(false /* delayed? */);
    16501651    }
    16511652}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.cpp

    r101559 r102836  
    241241        UIVirtualMachineItemCloud *pCloudMachineItem = cache()->toCloud();
    242242        AssertPtrReturnVoid(pCloudMachineItem);
    243         if (fSelected && pCloudMachineItem->accessible())
    244             pCloudMachineItem->updateInfoAsync(false /* delayed? */, true /* subscribe */);
    245         else
    246             pCloudMachineItem->stopAsyncUpdates();
     243        const bool fUpdateRequired = fSelected && pCloudMachineItem->accessible();
     244        pCloudMachineItem->setUpdateRequiredByLocalReason(fUpdateRequired);
     245        if (fUpdateRequired)
     246            pCloudMachineItem->updateInfoAsync(false /* delayed? */);
    247247    }
    248248}
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