VirtualBox

Ignore:
Timestamp:
Oct 8, 2014 12:24:10 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI rework/cleanup for 7115 (part #5): Better encapsulation for UIMachine (part #2).

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

Legend:

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

    r52977 r52991  
    221221    : mValid (false)
    222222    , mSelectorWnd (NULL)
    223     , m_pVirtualMachine(0)
    224223    , m_fSeparateProcess(false)
    225224    , m_pMediumEnumerator(0)
     
    374373}
    375374
    376 QWidget* VBoxGlobal::activeMachineWindow()
    377 {
    378     /* Null if that is NOT console-process or machine not yet created: */
    379     if (!isVMConsoleProcess() || !m_pVirtualMachine)
    380         return 0;
    381     /* Active machine-window otherwise: */
    382     return m_pVirtualMachine->activeWindow();
    383 }
    384 
     375UIMachine* VBoxGlobal::virtualMachine() const
     376{
     377    return gpMachine;
     378}
     379
     380QWidget* VBoxGlobal::activeMachineWindow() const
     381{
     382    if (isVMConsoleProcess() && gpMachine && gpMachine->activeWindow())
     383        return gpMachine->activeWindow();
     384    return 0;
     385}
    385386
    386387/**
     
    42464247        mSelectorWnd = NULL;
    42474248    }
    4248 
    4249     if (m_pVirtualMachine)
    4250     {
    4251         delete m_pVirtualMachine;
    4252         m_pVirtualMachine = NULL;
    4253     }
     4249    if (gpMachine)
     4250        UIMachine::destroy();
    42544251
    42554252    /* Cleanup medium-enumerator: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r52977 r52991  
    111111
    112112    /** Returns current virtual machine. */
    113     UIMachine* virtualMachine() const { return m_pVirtualMachine; }
    114     /** Defines current virtual @a pMachine. */
    115     void setVirtualMachine(UIMachine *pMachine) { m_pVirtualMachine = pMachine; }
    116 
    117     QWidget* activeMachineWindow();
     113    UIMachine* virtualMachine() const;
     114    /** Returns currently active virtual machine window. */
     115    QWidget* activeMachineWindow() const;
    118116
    119117    bool is3DAvailableWorker() const;
     
    437435
    438436    UISelectorWindow *mSelectorWnd;
    439     UIMachine *m_pVirtualMachine;
    440437
    441438    /** Holds whether GUI is separate (from VM) process. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r52989 r52991  
    9797
    9898/* static */
     99UIMachine* UIMachine::m_spInstance = 0;
     100
     101/* static */
    99102bool UIMachine::startMachine(const QString &strID)
    100103{
     
    136139
    137140    /* Create machine UI: */
    138     UIMachine *pMachine = new UIMachine;
    139 
     141    new UIMachine;
    140142    /* Prepare machine UI: */
    141     return pMachine->prepare();
     143    return m_spInstance->prepare();
     144}
     145
     146/* static */
     147void UIMachine::destroy()
     148{
     149    /* Cleanup machine UI: */
     150    m_spInstance->cleanup();
     151    /* Destroy machine UI: */
     152    delete m_spInstance;
     153    m_spInstance = 0;
    142154}
    143155
     
    195207    , m_pVisualState(0)
    196208{
    197     /* Make sure VBoxGlobal is aware of VM creation: */
    198     vboxGlobal().setVirtualMachine(this);
     209    m_spInstance = this;
    199210}
    200211
    201212UIMachine::~UIMachine()
    202213{
    203     /* Make sure VBoxGlobal is aware of VM destruction: */
    204     vboxGlobal().setVirtualMachine(0);
    205 
    206     /* Cleanup machine UI: */
    207     cleanup();
     214    m_spInstance = 0;
    208215}
    209216
     
    335342    m_session.detach();
    336343
    337     /* Make sure VBoxGlobal is aware of VM destruction: */
    338     vboxGlobal().setVirtualMachine(0);
    339 
    340344    /* Quit application: */
    341345    QApplication::quit();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r52989 r52991  
    5151      * @return true if machine was started, false otherwise. */
    5252    static bool startMachine(const QString &strID);
     53    /** Static destructor. */
     54    static void destroy();
     55    /** Static instance. */
     56    static UIMachine* instance() { return m_spInstance; }
    5357
    5458    /** Returns UI session instance. */
     
    8993    void enterInitialVisualState();
    9094
     95    /** Static instance. */
     96    static UIMachine* m_spInstance;
     97
    9198    /** Holds the session instance. */
    9299    CSession m_session;
     
    101108    /** Holds current visual state. */
    102109    UIVisualState *m_pVisualState;
    103 
    104     /* Temporary access: */
    105     friend class VBoxGlobal;
    106110};
    107111
     112#define gpMachine UIMachine::instance()
     113
    108114#endif /* !___UIMachine_h___ */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r52902 r52991  
    678678        if (!pWidget->isHidden())
    679679            pWidget->hide();
    680         /* Restart this slot asynchronously: */
     680        /* Restart this slot: */
    681681        emit sigCloseRuntimeUI();
    682682        return;
     
    684684
    685685    /* Finally close the Runtime UI: */
    686     m_pMachine->deleteLater();
     686    UIMachine::destroy();
    687687}
    688688
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