VirtualBox

Changeset 67275 in vbox for trunk


Ignore:
Timestamp:
Jun 6, 2017 2:26:42 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: Selector UI: Tools pane: Snapshot pane: Fixing race causing assertion on session state change related to snapshot being deleted.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp

    r67267 r67275  
    618618    /* Recache current session-state: */
    619619    m_enmSessionState = enmState;
    620     sltHandleCurrentItemChange();
     620
     621    /* Update action states: */
     622    updateActionStates();
    621623}
    622624
     
    715717    const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
    716718
    717     /* Make the selected item visible: */
     719    /* Make the current item visible: */
    718720    if (pSnapshotItem)
    719721    {
     
    723725    }
    724726
    725     /* Check whether another direct session is open or not: */
    726     const bool fBusy = m_enmSessionState != KSessionState_Unlocked;
    727 
    728     /* Acquire machine state of the "current state" item: */
    729     KMachineState enmState = KMachineState_Null;
    730     if (currentStateItem())
    731         enmState = currentStateItem()->machineState();
    732 
    733     /* Whether taking or deleting snapshots is possible right now: */
    734     const bool fCanTakeDeleteSnapshot =    !fBusy
    735                                         || enmState == KMachineState_PoweredOff
    736                                         || enmState == KMachineState_Saved
    737                                         || enmState == KMachineState_Aborted
    738                                         || enmState == KMachineState_Running
    739                                         || enmState == KMachineState_Paused;
    740 
    741     /* Enable/disable snapshot operations: */
    742     m_pActionTakeSnapshot->setEnabled(
    743            m_fShapshotOperationsAllowed
    744         && (   (   fCanTakeDeleteSnapshot
    745                 && m_pCurrentSnapshotItem
    746                 && pSnapshotItem
    747                 && pSnapshotItem->isCurrentStateItem())
    748             || (   pSnapshotItem
    749                 && !m_pCurrentSnapshotItem))
    750     );
    751     m_pActionDeleteSnapshot->setEnabled(
    752            m_fShapshotOperationsAllowed
    753         && fCanTakeDeleteSnapshot
    754         && m_pCurrentSnapshotItem
    755         && pSnapshotItem
    756         && !pSnapshotItem->isCurrentStateItem()
    757     );
    758     m_pActionRestoreSnapshot->setEnabled(
    759            !fBusy
    760         && m_pCurrentSnapshotItem
    761         && pSnapshotItem
    762         && !pSnapshotItem->isCurrentStateItem()
    763     );
    764     m_pActionShowSnapshotDetails->setEnabled(
    765         pSnapshotItem
    766     );
    767     m_pActionCommitSnapshotDetails->setEnabled(
    768         false
    769     );
    770     m_pActionCloneSnapshot->setEnabled(
    771            pSnapshotItem
    772         && (   !pSnapshotItem->isCurrentStateItem()
    773             || !fBusy)
    774     );
    775 
    776     /* If there is a proper snasphot item: */
    777     if (pSnapshotItem)
    778     {
    779         /* Update details-widget if it's visible: */
    780         if (m_pDetailsWidget->isVisible())
    781             m_pDetailsWidget->setData(*pSnapshotItem, pSnapshotItem->snapshot());
    782     }
     727    /* Update action states: */
     728    updateActionStates();
     729
     730    /* Update details-widget if it's visible: */
     731    if (pSnapshotItem && m_pDetailsWidget->isVisible())
     732        m_pDetailsWidget->setData(*pSnapshotItem, pSnapshotItem->snapshot());
    783733}
    784734
     
    10691019    QWriteLocker locker(m_pLockReadWrite);
    10701020
    1071     /* If VM is null, just updated the current itm: */
     1021    /* If VM is null, just updated the current item: */
    10721022    if (m_comMachine.isNull())
    10731023    {
     
    11821132    delete m_pLockReadWrite;
    11831133    m_pLockReadWrite = 0;
     1134}
     1135
     1136void UISnapshotPane::updateActionStates()
     1137{
     1138    /* Acquire current snapshot item: */
     1139    const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem());
     1140
     1141    /* Check whether another direct session is opened: */
     1142    const bool fBusy = m_enmSessionState != KSessionState_Unlocked;
     1143
     1144    /* Acquire machine-state of the "current state" item: */
     1145    KMachineState enmState = KMachineState_Null;
     1146    if (currentStateItem())
     1147        enmState = currentStateItem()->machineState();
     1148
     1149    /* Determine whether taking or deleting snapshots is possible: */
     1150    const bool fCanTakeDeleteSnapshot =    !fBusy
     1151                                        || enmState == KMachineState_PoweredOff
     1152                                        || enmState == KMachineState_Saved
     1153                                        || enmState == KMachineState_Aborted
     1154                                        || enmState == KMachineState_Running
     1155                                        || enmState == KMachineState_Paused;
     1156
     1157    /* Update 'Take' action: */
     1158    m_pActionTakeSnapshot->setEnabled(
     1159           m_fShapshotOperationsAllowed
     1160        && (   (   fCanTakeDeleteSnapshot
     1161                && m_pCurrentSnapshotItem
     1162                && pSnapshotItem
     1163                && pSnapshotItem->isCurrentStateItem())
     1164            || (   pSnapshotItem
     1165                && !m_pCurrentSnapshotItem))
     1166    );
     1167
     1168    /* Update 'Delete' action: */
     1169    m_pActionDeleteSnapshot->setEnabled(
     1170           m_fShapshotOperationsAllowed
     1171        && fCanTakeDeleteSnapshot
     1172        && m_pCurrentSnapshotItem
     1173        && pSnapshotItem
     1174        && !pSnapshotItem->isCurrentStateItem()
     1175    );
     1176
     1177    /* Update 'Restore' action: */
     1178    m_pActionRestoreSnapshot->setEnabled(
     1179           !fBusy
     1180        && m_pCurrentSnapshotItem
     1181        && pSnapshotItem
     1182        && !pSnapshotItem->isCurrentStateItem()
     1183    );
     1184
     1185    /* Update 'Show Details' action: */
     1186    m_pActionShowSnapshotDetails->setEnabled(
     1187        pSnapshotItem
     1188    );
     1189
     1190    /* Update 'Commit Details' action: */
     1191    m_pActionCommitSnapshotDetails->setEnabled(
     1192        false
     1193    );
     1194
     1195    /* Update 'Clone' action: */
     1196    m_pActionCloneSnapshot->setEnabled(
     1197           pSnapshotItem
     1198        && (   !pSnapshotItem->isCurrentStateItem()
     1199            || !fBusy)
     1200    );
    11841201}
    11851202
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h

    r67262 r67275  
    153153    /** @name Toolbar helpers.
    154154      * @{ */
     155        /** Updates action states. */
     156        void updateActionStates();
     157
    155158        /** Proposes to take a snapshot. */
    156159        bool takeSnapshot();
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