VirtualBox

Changeset 98926 in vbox for trunk


Ignore:
Timestamp:
Mar 13, 2023 10:05:36 AM (23 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10322: A bit of cleanup and sanity for openSession and startMachine stuff.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r98885 r98926  
    13341334}
    13351335
    1336 CSession UICommon::openSession(const QUuid &uId, KLockType lockType /* = KLockType_Shared */)
     1336CSession UICommon::openSession(QUuid uId, KLockType enmLockType /* = KLockType_Write */)
    13371337{
    13381338    /* Prepare session: */
    13391339    CSession comSession;
     1340
     1341    /* Make sure uId isn't null: */
     1342    if (uId.isNull())
     1343        uId = managedVMUuid();
     1344    if (uId.isNull())
     1345        return comSession;
    13401346
    13411347    /* Simulate try-catch block: */
     
    13591365        }
    13601366
    1361         if (lockType == KLockType_VM)
     1367        if (enmLockType == KLockType_VM)
    13621368            comSession.SetName("GUI/Qt");
    13631369
    13641370        /* Lock found machine to session: */
    1365         comMachine.LockMachine(comSession, lockType);
     1371        comMachine.LockMachine(comSession, enmLockType);
    13661372        if (!comMachine.isOk())
    13671373        {
     
    13911397    /* Return session: */
    13921398    return comSession;
     1399}
     1400
     1401CSession UICommon::openSession(KLockType enmLockType /* = KLockType_Write */)
     1402{
     1403    /* Pass to function above: */
     1404    return openSession(managedVMUuid(), enmLockType);
    13931405}
    13941406
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r98885 r98926  
    336336
    337337        /** Opens session of certain @a enmLockType for VM with certain @a uId. */
    338         CSession openSession(const QUuid &uId, KLockType enmLockType = KLockType_Write);
     338        CSession openSession(QUuid uId, KLockType enmLockType = KLockType_Write);
     339        /** Opens session of certain @a enmLockType for currently chosen VM. */
     340        CSession openSession(KLockType enmLockType = KLockType_Write);
    339341        /** Opens session of KLockType_Shared type for VM with certain @a uId. */
    340342        CSession openExistingSession(const QUuid &uId) { return openSession(uId, KLockType_Shared); }
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIStarter.cpp

    r98890 r98926  
    101101
    102102    /* Try to start virtual machine, quit if failed: */
    103     if (!UIMachine::startMachine(uiCommon().managedVMUuid()))
     103    if (!UIMachine::startMachine())
    104104        return QApplication::quit();
    105105
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r98903 r98926  
    113113
    114114/* static */
    115 bool UIMachine::startMachine(const QUuid &uID)
     115bool UIMachine::startMachine()
    116116{
    117117    /* Make sure machine is not created: */
     
    122122    {
    123123        /* Create temporary session: */
    124         CSession session = uiCommon().openSession(uID, KLockType_VM);
    125         if (session.isNull())
     124        CSession comSession = uiCommon().openSession(KLockType_VM);
     125        if (comSession.isNull())
    126126            return false;
    127127
    128128        /* Which VM we operate on? */
    129         CMachine machine = session.GetMachine();
     129        CMachine comMachine = comSession.GetMachine();
    130130        /* Which snapshot we are restoring? */
    131         CSnapshot snapshot = machine.GetCurrentSnapshot();
     131        CSnapshot comSnapshot = comMachine.GetCurrentSnapshot();
    132132
    133133        /* Prepare restore-snapshot progress: */
    134         CProgress progress = machine.RestoreSnapshot(snapshot);
    135         if (!machine.isOk())
    136             return msgCenter().cannotRestoreSnapshot(machine, snapshot.GetName(), machine.GetName());
     134        CProgress comProgress = comMachine.RestoreSnapshot(comSnapshot);
     135        if (!comMachine.isOk())
     136            return msgCenter().cannotRestoreSnapshot(comMachine, comSnapshot.GetName(), comMachine.GetName());
    137137
    138138        /* Show the snapshot-discarding progress: */
    139         msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_snapshot_discard_90px.png");
    140         if (progress.GetResultCode() != 0)
    141             return msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName(), machine.GetName());
     139        msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(), ":/progress_snapshot_discard_90px.png");
     140        if (comProgress.GetResultCode() != 0)
     141            return msgCenter().cannotRestoreSnapshot(comProgress, comSnapshot.GetName(), comMachine.GetName());
    142142
    143143        /* Unlock session finally: */
    144         session.UnlockMachine();
     144        comSession.UnlockMachine();
    145145
    146146        /* Clear snapshot-restoring request: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98903 r98926  
    154154public:
    155155
    156     /** Static factory to start machine with passed @a uID.
    157       * @return true if machine was started, false otherwise. */
    158     static bool startMachine(const QUuid &uID);
     156    /** Static factory to start machine. */
     157    static bool startMachine();
    159158    /** Static constructor. */
    160159    static bool create();
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