VirtualBox

Changeset 39296 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 14, 2011 1:24:53 PM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: 5947: VM induces a notable CPU load if suspended: LED update timer changed from 50ms to 500ms and disabled for the states corresponding to paused VM.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal
Files:
2 edited

Legend:

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

    r38476 r39296  
    126126{
    127127    UIMachineWindow::sltMachineStateChanged();
    128     updateAppearanceOf(UIVisualElement_VirtualizationStuff);
     128    updateAppearanceOf(UIVisualElement_PauseStuff | UIVisualElement_VirtualizationStuff);
    129129}
    130130
     
    193193void UIMachineWindowNormal::sltUpdateIndicators()
    194194{
    195     CConsole console = session().GetConsole();
    196     QIStateIndicator *pStateIndicator = 0;
    197 
    198     pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_HardDisks);
    199     if (pStateIndicator->state() != KDeviceActivity_Null)
    200     {
    201         int state = console.GetDeviceActivity(KDeviceType_HardDisk);
    202         if (pStateIndicator->state() != state)
    203             pStateIndicator->setState(state);
    204     }
    205     pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks);
    206     if (pStateIndicator->state() != KDeviceActivity_Null)
    207     {
    208         int state = console.GetDeviceActivity(KDeviceType_DVD);
    209         if (pStateIndicator->state() != state)
    210             pStateIndicator->setState(state);
    211     }
    212     pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_FloppyDisks);
    213     if (pStateIndicator->state() != KDeviceActivity_Null)
    214     {
    215         int state = console.GetDeviceActivity(KDeviceType_Floppy);
    216         if (pStateIndicator->state() != state)
    217             pStateIndicator->setState(state);
    218     }
    219     pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_USBDevices);
    220     if (pStateIndicator->state() != KDeviceActivity_Null)
    221     {
    222         int state = console.GetDeviceActivity(KDeviceType_USB);
    223         if (pStateIndicator->state() != state)
    224             pStateIndicator->setState(state);
    225     }
    226     pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters);
    227     if (pStateIndicator->state() != KDeviceActivity_Null)
    228     {
    229         int state = console.GetDeviceActivity(KDeviceType_Network);
    230         if (pStateIndicator->state() != state)
    231             pStateIndicator->setState(state);
    232     }
    233     pStateIndicator = indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders);
    234     if (pStateIndicator->state() != KDeviceActivity_Null)
    235     {
    236         int state = console.GetDeviceActivity(KDeviceType_SharedFolder);
    237         if (pStateIndicator->state() != state)
    238             pStateIndicator->setState(state);
    239     }
     195    updateIndicatorState(indicatorsPool()->indicator(UIIndicatorIndex_HardDisks), KDeviceType_HardDisk);
     196    updateIndicatorState(indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks), KDeviceType_DVD);
     197    updateIndicatorState(indicatorsPool()->indicator(UIIndicatorIndex_FloppyDisks), KDeviceType_Floppy);
     198    updateIndicatorState(indicatorsPool()->indicator(UIIndicatorIndex_USBDevices), KDeviceType_USB);
     199    updateIndicatorState(indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters), KDeviceType_Network);
     200    updateIndicatorState(indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders), KDeviceType_SharedFolder);
    240201}
    241202
     
    298259
    299260    /* Update that machine window: */
     261    if (iElement & UIVisualElement_PauseStuff)
     262    {
     263        if (uisession()->isPaused() && m_pIdleTimer->isActive())
     264            m_pIdleTimer->stop();
     265        else if (uisession()->isRunning() && !m_pIdleTimer->isActive())
     266            m_pIdleTimer->start(500);
     267        sltUpdateIndicators();
     268    }
    300269    if (iElement & UIVisualElement_HDStuff)
    301270        indicatorsPool()->indicator(UIIndicatorIndex_HardDisks)->updateAppearance();
     
    482451    m_pIdleTimer = new QTimer(this);
    483452    connect(m_pIdleTimer, SIGNAL(timeout()), this, SLOT(sltUpdateIndicators()));
    484     m_pIdleTimer->start(50);
     453    m_pIdleTimer->start(500);
    485454
    486455#ifdef Q_WS_MAC
     
    707676}
    708677
     678void UIMachineWindowNormal::updateIndicatorState(QIStateIndicator *pIndicator, KDeviceType deviceType)
     679{
     680    /* Do NOT update indicators with NULL state: */
     681    if (pIndicator->state() == KDeviceActivity_Null)
     682        return;
     683
     684    /* Paused VM have all indicator states set to IDLE: */
     685    bool fPaused = uisession()->isPaused();
     686    if (fPaused)
     687    {
     688        /* If state differs from IDLE => set IDLE one:  */
     689        if (pIndicator->state() != KDeviceActivity_Idle)
     690            pIndicator->setState(KDeviceActivity_Idle);
     691    }
     692    else
     693    {
     694        /* Get current indicator state: */
     695        int state = session().GetConsole().GetDeviceActivity(deviceType);
     696        /* If state differs => set new one:  */
     697        if (pIndicator->state() != state)
     698            pIndicator->setState(state);
     699    }
     700}
     701
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.h

    r38476 r39296  
    2727#include "QIWithRetranslateUI.h"
    2828#include "UIMachineWindow.h"
     29#include "COMDefs.h"
    2930
    3031/* Local forwards */
     
    104105    void showSimple();
    105106    bool isMaximizedChecked();
     107    void updateIndicatorState(QIStateIndicator *pIndicator, KDeviceType deviceType);
    106108
    107109    /* Indicators pool: */
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