VirtualBox

Changeset 98902 in vbox


Ignore:
Timestamp:
Mar 10, 2023 2:20:21 PM (21 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10322: Runtime UI: Simplify UISession creation and prepare procedures.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
3 edited

Legend:

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

    r98882 r98902  
    172172    /* Create machine UI: */
    173173    new UIMachine;
     174
    174175    /* Make sure it's prepared: */
    175176    if (!s_pInstance->prepare())
     
    180181        return false;
    181182    }
     183
    182184    /* True by default: */
    183185    return true;
     
    14561458bool UIMachine::prepare()
    14571459{
    1458     /* Try to create session UI: */
    1459     if (!UISession::create(m_pSession, this))
     1460    /* Create session UI: */
     1461    m_pSession = new UISession(this);
     1462    AssertPtrReturn(uisession(), false);
     1463    /* And make sure it's prepared: */
     1464    if (!uisession()->prepare())
    14601465        return false;
    1461     AssertPtrReturn(uisession(), false);
    14621466
    14631467    /* Prepare stuff: */
     
    18131817{
    18141818    /* Destroy session UI if exists: */
    1815     if (uisession())
    1816         UISession::destroy(m_pSession);
     1819    delete m_pSession;
     1820    m_pSession = 0;
    18171821}
    18181822
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98882 r98902  
    105105#endif
    106106
    107 /* static */
    108 bool UISession::create(UISession *&pSession, UIMachine *pMachine)
    109 {
    110     /* Make sure NULL pointer passed: */
    111     AssertReturn(!pSession, false);
    112 
    113     /* Create session UI: */
    114     pSession = new UISession(pMachine);
    115     AssertPtrReturn(pSession, false);
    116 
    117     /* Make sure it's prepared: */
    118     if (!pSession->prepare())
    119     {
    120         /* Destroy session UI otherwise: */
    121         destroy(pSession);
    122         /* False in that case: */
     107UISession::UISession(UIMachine *pMachine)
     108    : QObject(pMachine)
     109    /* Base variables: */
     110    , m_pMachine(pMachine)
     111    , m_pConsoleEventhandler(0)
     112    /* Common variables: */
     113    , m_enmMachineStatePrevious(KMachineState_Null)
     114    , m_enmMachineState(KMachineState_Null)
     115    /* Guest additions flags: */
     116    , m_ulGuestAdditionsRunLevel(0)
     117    , m_fIsGuestSupportsGraphics(false)
     118    , m_fIsGuestSupportsSeamless(false)
     119#ifdef VBOX_WITH_DEBUGGER_GUI
     120    /* Debug UI stuff: */
     121    , m_pDbgGui(0)
     122    , m_pDbgGuiVT(0)
     123#endif /* VBOX_WITH_DEBUGGER_GUI */
     124{
     125}
     126
     127bool UISession::prepare()
     128{
     129    /* Prepare COM stuff: */
     130    if (!prepareSession())
    123131        return false;
    124     }
     132
     133    /* Cache media early if requested: */
     134    if (uiCommon().agressiveCaching())
     135        recacheMachineMedia();
     136
     137    /* Prepare GUI stuff: */
     138    prepareNotificationCenter();
     139    prepareConsoleEventHandlers();
     140    prepareFramebuffers();
     141    prepareConnections();
     142    prepareSignalHandling();
    125143
    126144    /* True by default: */
    127145    return true;
    128 }
    129 
    130 /* static */
    131 void UISession::destroy(UISession *&pSession)
    132 {
    133     /* Make sure valid pointer passed: */
    134     AssertPtrReturnVoid(pSession);
    135 
    136     /* Delete session: */
    137     delete pSession;
    138     pSession = 0;
    139146}
    140147
     
    22322239    cleanupConsoleEventHandlers();
    22332240    cleanupNotificationCenter();
    2234     cleanupSession();
     2241    cleanupCOMStuff();
    22352242}
    22362243
     
    23222329    /* Close Runtime UI independent of snapshot restoring state: */
    23232330    uimachine()->closeRuntimeUI();
    2324 }
    2325 
    2326 UISession::UISession(UIMachine *pMachine)
    2327     : QObject(pMachine)
    2328     /* Base variables: */
    2329     , m_pMachine(pMachine)
    2330     , m_pConsoleEventhandler(0)
    2331     /* Common variables: */
    2332     , m_enmMachineStatePrevious(KMachineState_Null)
    2333     , m_enmMachineState(KMachineState_Null)
    2334     /* Guest additions flags: */
    2335     , m_ulGuestAdditionsRunLevel(0)
    2336     , m_fIsGuestSupportsGraphics(false)
    2337     , m_fIsGuestSupportsSeamless(false)
    2338 #ifdef VBOX_WITH_DEBUGGER_GUI
    2339     /* Debug UI stuff: */
    2340     , m_pDbgGui(0)
    2341     , m_pDbgGuiVT(0)
    2342 #endif /* VBOX_WITH_DEBUGGER_GUI */
    2343 {
    2344 }
    2345 
    2346 UISession::~UISession()
    2347 {
    2348 }
    2349 
    2350 bool UISession::prepare()
    2351 {
    2352     /* Prepare COM stuff: */
    2353     if (!prepareSession())
    2354         return false;
    2355 
    2356     /* Cache media early if requested: */
    2357     if (uiCommon().agressiveCaching())
    2358         recacheMachineMedia();
    2359 
    2360     /* Prepare GUI stuff: */
    2361     prepareNotificationCenter();
    2362     prepareConsoleEventHandlers();
    2363     prepareFramebuffers();
    2364     prepareConnections();
    2365     prepareSignalHandling();
    2366 
    2367     /* True by default: */
    2368     return true;
    23692331}
    23702332
     
    25472509}
    25482510
    2549 void UISession::cleanupSession()
     2511void UISession::cleanupCOMStuff()
    25502512{
    25512513    /* Detach debugger: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98882 r98902  
    146146public:
    147147
    148     /** Constructs session UI passing @a pMachine to the constructor.
    149       * @param  pSession  Brings the pointer to the session UI being constructed.
     148    /** Constructs session UI passing @a pMachine to the base-class.
    150149      * @param  pMachine  Brings the machine UI reference. */
    151     static bool create(UISession *&pSession, UIMachine *pMachine);
    152     /** Destructs session UI.
    153       * @param  pSession  Brings the pointer to the session UI being destructed. */
    154     static void destroy(UISession *&pSession);
     150    UISession(UIMachine *pMachine);
    155151
    156152    /** @name General stuff.
    157153     ** @{ */
     154        /** Prepares everything. */
     155        bool prepare();
    158156        /** Performs session UI intialization. */
    159157        bool initialize();
     
    648646private:
    649647
    650     /** Constructs session UI passing @a pMachine to the base-class.
    651       * @param  pMachine  Brings the machine UI reference. */
    652     UISession(UIMachine *pMachine);
    653     /** Destructs session UI. */
    654     virtual ~UISession() RT_OVERRIDE;
    655 
    656648    /** @name Prepare/cleanup cascade.
    657649     ** @{ */
    658         /** Prepares everything. */
    659         bool prepare();
    660650        /** Prepares COM session. */
    661651        bool prepareSession();
     
    677667        /** Cleanups notification-center. */
    678668        void cleanupNotificationCenter();
    679         /** Cleanups COM session. */
    680         void cleanupSession();
     669        /** Cleanups COM stuff. */
     670        void cleanupCOMStuff();
    681671    /** @} */
    682672
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