VirtualBox

Changeset 79889 in vbox


Ignore:
Timestamp:
Jul 19, 2019 3:45:15 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
132293
Message:

FE/Qt: bugref:7720: Extend UICommon with API which automatically detects which type of session needs to be opened for passed VM if any at all.

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

Legend:

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

    r79365 r79889  
    24932493}
    24942494
     2495CSession UICommon::tryToOpenSessionFor(CMachine &comMachine)
     2496{
     2497    /* Prepare session: */
     2498    CSession comSession;
     2499
     2500    /* Session state unlocked? */
     2501    if (comMachine.GetSessionState() == KSessionState_Unlocked)
     2502    {
     2503        /* Open own 'write' session: */
     2504        comSession = openSession(comMachine.GetId());
     2505        AssertReturn(!comSession.isNull(), CSession());
     2506        comMachine = comSession.GetMachine();
     2507    }
     2508    /* Is this a Selector UI call? */
     2509    else if (uiType() == UIType_SelectorUI)
     2510    {
     2511        /* Open existing 'shared' session: */
     2512        comSession = openExistingSession(comMachine.GetId());
     2513        AssertReturn(!comSession.isNull(), CSession());
     2514        comMachine = comSession.GetMachine();
     2515    }
     2516    /* Else this is Runtime UI call
     2517     * which has session locked for itself. */
     2518
     2519    /* Return session: */
     2520    return comSession;
     2521}
     2522
    24952523void UICommon::startMediumEnumeration(const CMediumVector &comMedia /* = CMediumVector() */)
    24962524{
     
    32443272        return;
    32453273
    3246     /* Get editable machine: */
    3247     CSession comSession;
     3274    /* Get editable machine & session: */
    32483275    CMachine comMachine = comConstMachine;
    3249     KSessionState enmSessionState = comMachine.GetSessionState();
    3250     /* Session state unlocked? */
    3251     if (enmSessionState == KSessionState_Unlocked)
    3252     {
    3253         /* Open own 'write' session: */
    3254         comSession = openSession(comMachine.GetId());
    3255         AssertReturnVoid(!comSession.isNull());
    3256         comMachine = comSession.GetMachine();
    3257     }
    3258     /* Is this a Selector UI call? */
    3259     else if (uiType() == UIType_SelectorUI)
    3260     {
    3261         /* Open existing 'shared' session: */
    3262         comSession = openExistingSession(comMachine.GetId());
    3263         AssertReturnVoid(!comSession.isNull());
    3264         comMachine = comSession.GetMachine();
    3265     }
    3266     /* Else this is Runtime UI call
    3267      * which has session locked for itself. */
     3276    CSession comSession = tryToOpenSessionFor(comMachine);
    32683277
    32693278    /* Remount medium to the predefined port/device: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r79365 r79889  
    472472        /** Opens session of KLockType_Shared type for VM with certain @a uId. */
    473473        CSession openExistingSession(const QUuid &uId) { return openSession(uId, KLockType_Shared); }
     474        /** Tries to guess if new @a comSession needs to be opened for certain @a comMachine,
     475          * if yes, new session of required type will be opened and machine will be updated,
     476          * otherwise, no session will be created and machine will be left unchanged. */
     477        CSession tryToOpenSessionFor(CMachine &comMachine);
    474478    /** @} */
    475479
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