VirtualBox

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


Ignore:
Timestamp:
May 30, 2013 1:43:23 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86105
Message:

FE/Qt: 6756: Selector UI: Details-view: Machine-preview: Do not cache the machine-state, always try to use the actual one, accessible through the CMachine getter.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGMachinePreview.cpp

    r45223 r46332  
    4949UIGMachinePreview::UIGMachinePreview(QIGraphicsWidget *pParent)
    5050    : QIWithRetranslateUI4<QIGraphicsWidget>(pParent)
    51     , m_machineState(KMachineState_Null)
    5251    , m_pUpdateTimer(new QTimer(this))
    5352    , m_pUpdateTimerMenu(0)
     
    9291    connect(m_pUpdateTimer, SIGNAL(timeout()), this, SLOT(sltRecreatePreview()));
    9392    connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)),
    94             this, SLOT(sltMachineStateChange(QString, KMachineState)));
     93            this, SLOT(sltMachineStateChange(QString)));
    9594
    9695    /* Retranslate the UI */
     
    123122}
    124123
    125 void UIGMachinePreview::sltMachineStateChange(QString strId, KMachineState state)
    126 {
    127     if (!m_machine.isNull() && m_machine.GetId() == strId)
    128     {
    129         /* Cache the machine state: */
    130         m_machineState = state;
    131         restart();
    132     }
     124void UIGMachinePreview::sltMachineStateChange(QString strId)
     125{
     126    /* Make sure its the event for our machine: */
     127    if (m_machine.isNull() || m_machine.GetId() != strId)
     128        return;
     129
     130    /* Restart the preview: */
     131    restart();
    133132}
    134133
     
    139138        return;
    140139
    141     /* Remove preview if any: */
     140    /* Cleanup preview first: */
    142141    if (m_pPreviewImg)
    143142    {
     
    146145    }
    147146
    148     /* We are not creating preview for inaccessible VMs: */
    149     if (m_machineState == KMachineState_Null)
    150         return;
    151 
    152     if (!m_machine.isNull() && m_vRect.width() > 0 && m_vRect.height() > 0)
     147    /* Fetch the latest machine-state: */
     148    KMachineState machineState = m_machine.isNull() ? KMachineState_Null : m_machine.GetState();
     149
     150    /* We are creating preview only for assigned and accessible VMs: */
     151    if (!m_machine.isNull() && machineState != KMachineState_Null &&
     152        m_vRect.width() > 0 && m_vRect.height() > 0)
    153153    {
    154154        QImage image(size().toSize(), QImage::Format_ARGB32);
     
    161161        {
    162162            /* Use the image which may be included in the save state. */
    163             if (m_machineState == KMachineState_Saved || m_machineState == KMachineState_Restoring)
     163            if (machineState == KMachineState_Saved || machineState == KMachineState_Restoring)
    164164            {
    165165                ULONG width = 0, height = 0;
     
    168168                {
    169169                    QImage shot = QImage::fromData(screenData.data(), screenData.size(), "PNG")
    170                             .scaled(m_vRect.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
     170                                  .scaled(m_vRect.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    171171                    dimImage(shot);
    172172                    painter.drawImage(m_vRect.x(), m_vRect.y(), shot);
     
    175175            }
    176176            /* Use the current VM output. */
    177             else if (m_machineState == KMachineState_Running || m_machineState == KMachineState_Paused)
     177            else if (machineState == KMachineState_Running || machineState == KMachineState_Paused)
    178178            {
    179179                if (m_session.GetState() == KSessionState_Locked)
     
    210210                                QImage shot = QImage((uchar*)d, m_vRect.width(), m_vRect.height(), QImage::Format_RGB32);
    211211
    212                                 if (m_machineState == KMachineState_Paused)
     212                                if (machineState == KMachineState_Paused)
    213213                                    dimImage(shot);
    214214                                painter.drawImage(m_vRect.x(), m_vRect.y(), shot);
     
    220220            }
    221221        }
     222
    222223        if (fDone)
    223224            m_pPreviewImg = new QImage(image);
    224225    }
     226
     227    /* Redraw preview in any case! */
    225228    update();
    226229}
     
    378381void UIGMachinePreview::restart()
    379382{
     383    /* Fetch the latest machine-state: */
     384    KMachineState machineState = m_machine.isNull() ? KMachineState_Null : m_machine.GetState();
     385
    380386    /* Reopen session if necessary: */
    381387    if (m_session.GetState() == KSessionState_Locked)
     
    383389    if (!m_machine.isNull())
    384390    {
    385         /* Fetch the latest machine state: */
    386         m_machineState = m_machine.GetState();
    387391        /* Lock the session for the current machine: */
    388         if (m_machineState == KMachineState_Running || m_machineState == KMachineState_Paused)
     392        if (machineState == KMachineState_Running || machineState == KMachineState_Paused)
    389393            m_machine.LockMachine(m_session, KLockType_Shared);
    390394    }
     
    396400    if (!m_machine.isNull())
    397401    {
    398         if (m_pUpdateTimer->interval() > 0 && m_machineState == KMachineState_Running)
     402        if (m_pUpdateTimer->interval() > 0 && machineState == KMachineState_Running)
    399403            m_pUpdateTimer->start();
    400404    }
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGMachinePreview.h

    r45223 r46332  
    7373private slots:
    7474
    75     /* Handler: Global-event listener: */
    76     void sltMachineStateChange(QString strId, KMachineState state);
     75    /* Handler: Global-event listener stuff: */
     76    void sltMachineStateChange(QString strId);
    7777
    7878    /* Handler: Preview recreator: */
     
    105105    CSession m_session;
    106106    CMachine m_machine;
    107     KMachineState m_machineState;
    108107    QTimer *m_pUpdateTimer;
    109108    QMenu *m_pUpdateTimerMenu;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette