VirtualBox

Changeset 60225 in vbox for trunk/src


Ignore:
Timestamp:
Mar 28, 2016 3:58:32 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: ​​​bugref:8308: Event handlers rework/cleanup (part 04): Better prepare/cleanup decomposition.

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

Legend:

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

    r60224 r60225  
    2222/* GUI includes: */
    2323# include "UIConsoleEventHandler.h"
    24 # include "UIMainEventListener.h"
    2524# include "VBoxGlobal.h"
    2625# include "UISession.h"
     
    7170void UIConsoleEventHandler::prepare()
    7271{
     72    /* Prepare: */
     73    prepareListener();
     74    prepareConnections();
     75}
     76
     77void UIConsoleEventHandler::prepareListener()
     78{
    7379    /* Make sure session is passed: */
    7480    AssertPtrReturnVoid(m_pSession);
    7581
    7682    /* Create Main event listener instance: */
    77     ComObjPtr<UIMainEventListenerImpl> pListener;
    78     pListener.createObject();
    79     pListener->init(new UIMainEventListener, this);
    80     m_mainEventListener = CEventListener(pListener);
     83    m_pQtListener.createObject();
     84    m_pQtListener->init(new UIMainEventListener, this);
     85    m_comEventListener = CEventListener(m_pQtListener);
    8186
    8287    /* Get console: */
     
    108113        << KVBoxEventType_OnCanShowWindow
    109114        << KVBoxEventType_OnShowWindow;
    110     eventSource.RegisterListener(m_mainEventListener, events, TRUE);
    111 
    112 
     115    eventSource.RegisterListener(m_comEventListener, events, TRUE);
     116}
     117
     118void UIConsoleEventHandler::prepareConnections()
     119{
    113120    /* Create queued (async) connections for non-waitable signals: */
    114     connect(pListener->getWrapped(), SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)),
     121    connect(m_pQtListener->getWrapped(), SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)),
    115122            this, SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)),
    116123            Qt::QueuedConnection);
    117     connect(pListener->getWrapped(), SIGNAL(sigMouseCapabilityChange(bool, bool, bool, bool)),
     124    connect(m_pQtListener->getWrapped(), SIGNAL(sigMouseCapabilityChange(bool, bool, bool, bool)),
    118125            this, SIGNAL(sigMouseCapabilityChange(bool, bool, bool, bool)),
    119126            Qt::QueuedConnection);
    120     connect(pListener->getWrapped(), SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)),
     127    connect(m_pQtListener->getWrapped(), SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)),
    121128            this, SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)),
    122129            Qt::QueuedConnection);
    123     connect(pListener->getWrapped(), SIGNAL(sigStateChange(KMachineState)),
     130    connect(m_pQtListener->getWrapped(), SIGNAL(sigStateChange(KMachineState)),
    124131            this, SIGNAL(sigStateChange(KMachineState)),
    125132            Qt::QueuedConnection);
    126     connect(pListener->getWrapped(), SIGNAL(sigAdditionsChange()),
     133    connect(m_pQtListener->getWrapped(), SIGNAL(sigAdditionsChange()),
    127134            this, SIGNAL(sigAdditionsChange()),
    128135            Qt::QueuedConnection);
    129     connect(pListener->getWrapped(), SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)),
     136    connect(m_pQtListener->getWrapped(), SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)),
    130137            this, SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)),
    131138            Qt::QueuedConnection);
    132     connect(pListener->getWrapped(), SIGNAL(sigStorageDeviceChange(CMediumAttachment, bool, bool)),
     139    connect(m_pQtListener->getWrapped(), SIGNAL(sigStorageDeviceChange(CMediumAttachment, bool, bool)),
    133140            this, SIGNAL(sigStorageDeviceChange(CMediumAttachment, bool, bool)),
    134141            Qt::QueuedConnection);
    135     connect(pListener->getWrapped(), SIGNAL(sigMediumChange(CMediumAttachment)),
     142    connect(m_pQtListener->getWrapped(), SIGNAL(sigMediumChange(CMediumAttachment)),
    136143            this, SIGNAL(sigMediumChange(CMediumAttachment)),
    137144            Qt::QueuedConnection);
    138     connect(pListener->getWrapped(), SIGNAL(sigVRDEChange()),
     145    connect(m_pQtListener->getWrapped(), SIGNAL(sigVRDEChange()),
    139146            this, SIGNAL(sigVRDEChange()),
    140147            Qt::QueuedConnection);
    141     connect(pListener->getWrapped(), SIGNAL(sigVideoCaptureChange()),
     148    connect(m_pQtListener->getWrapped(), SIGNAL(sigVideoCaptureChange()),
    142149            this, SIGNAL(sigVideoCaptureChange()),
    143150            Qt::QueuedConnection);
    144     connect(pListener->getWrapped(), SIGNAL(sigUSBControllerChange()),
     151    connect(m_pQtListener->getWrapped(), SIGNAL(sigUSBControllerChange()),
    145152            this, SIGNAL(sigUSBControllerChange()),
    146153            Qt::QueuedConnection);
    147     connect(pListener->getWrapped(), SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)),
     154    connect(m_pQtListener->getWrapped(), SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)),
    148155            this, SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)),
    149156            Qt::QueuedConnection);
    150     connect(pListener->getWrapped(), SIGNAL(sigSharedFolderChange()),
     157    connect(m_pQtListener->getWrapped(), SIGNAL(sigSharedFolderChange()),
    151158            this, SIGNAL(sigSharedFolderChange()),
    152159            Qt::QueuedConnection);
    153     connect(pListener->getWrapped(), SIGNAL(sigCPUExecutionCapChange()),
     160    connect(m_pQtListener->getWrapped(), SIGNAL(sigCPUExecutionCapChange()),
    154161            this, SIGNAL(sigCPUExecutionCapChange()),
    155162            Qt::QueuedConnection);
    156     connect(pListener->getWrapped(), SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)),
     163    connect(m_pQtListener->getWrapped(), SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)),
    157164            this, SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)),
    158165            Qt::QueuedConnection);
    159     connect(pListener->getWrapped(), SIGNAL(sigRuntimeError(bool, QString, QString)),
     166    connect(m_pQtListener->getWrapped(), SIGNAL(sigRuntimeError(bool, QString, QString)),
    160167            this, SIGNAL(sigRuntimeError(bool, QString, QString)),
    161168            Qt::QueuedConnection);
    162169
    163170    /* Create direct (sync) connections for waitable signals: */
    164     connect(pListener->getWrapped(), SIGNAL(sigCanShowWindow(bool &, QString &)),
     171    connect(m_pQtListener->getWrapped(), SIGNAL(sigCanShowWindow(bool &, QString &)),
    165172            this, SLOT(sltCanShowWindow(bool &, QString &)),
    166173            Qt::DirectConnection);
    167     connect(pListener->getWrapped(), SIGNAL(sigShowWindow(qint64 &)),
     174    connect(m_pQtListener->getWrapped(), SIGNAL(sigShowWindow(qint64 &)),
    168175            this, SLOT(sltShowWindow(qint64 &)),
    169176            Qt::DirectConnection);
    170177}
    171178
    172 void UIConsoleEventHandler::cleanup()
     179void UIConsoleEventHandler::cleanupConnections()
     180{
     181    /* Nothing for now. */
     182}
     183
     184void UIConsoleEventHandler::cleanupListener()
    173185{
    174186    /* Make sure session is passed: */
     
    183195    AssertWrapperOk(eventSource);
    184196    /* Unregister listener: */
    185     eventSource.UnregisterListener(m_mainEventListener);
     197    eventSource.UnregisterListener(m_comEventListener);
     198}
     199
     200void UIConsoleEventHandler::cleanup()
     201{
     202    /* Cleanup: */
     203    cleanupConnections();
     204    cleanupListener();
    186205}
    187206
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIConsoleEventHandler.h

    r60224 r60225  
    2121/* Qt includes: */
    2222#include <QObject>
     23
     24/* GUI includes: */
     25#include "UIMainEventListener.h"
    2326
    2427/* COM includes: */
     
    9598    ~UIConsoleEventHandler();
    9699
    97     /** Prepares all. */
    98     void prepare();
    99     /** Cleanups all. */
    100     void cleanup();
     100    /** @name Prepare/Cleanup cascade.
     101      * @{ */
     102        /** Prepares all. */
     103        void prepare();
     104        /** Prepares listener. */
     105        void prepareListener();
     106        /** Prepares connections. */
     107        void prepareConnections();
     108
     109        /** Cleanups connections. */
     110        void cleanupConnections();
     111        /** Cleanups listener. */
     112        void cleanupListener();
     113        /** Cleanups all. */
     114        void cleanup();
     115    /** @} */
    101116
    102117private slots:
     
    112127    static UIConsoleEventHandler *m_spInstance;
    113128
     129    /** Holds the Qt event listener instance. */
     130    ComObjPtr<UIMainEventListenerImpl> m_pQtListener;
    114131    /** Holds the COM event listener instance. */
    115     CEventListener m_mainEventListener;
     132    CEventListener m_comEventListener;
    116133
    117134    /** Holds the UI session reference. */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.cpp

    r60223 r60225  
    2222/* GUI includes: */
    2323# include "UIVirtualBoxEventHandler.h"
    24 # include "UIMainEventListener.h"
    2524# include "VBoxGlobal.h"
    2625
     
    6665void UIVirtualBoxEventHandler::prepare()
    6766{
     67    /* Prepare: */
     68    prepareListener();
     69    prepareConnections();
     70}
     71
     72void UIVirtualBoxEventHandler::prepareListener()
     73{
    6874    /* Create Main event listener instance: */
    69     ComObjPtr<UIMainEventListenerImpl> pListener;
    70     pListener.createObject();
    71     pListener->init(new UIMainEventListener, this);
    72     m_mainEventListener = CEventListener(pListener);
     75    m_pQtListener.createObject();
     76    m_pQtListener->init(new UIMainEventListener, this);
     77    m_comEventListener = CEventListener(m_pQtListener);
    7378
    7479    /* Get VirtualBoxClient: */
     
    8287    vboxClientEvents
    8388        << KVBoxEventType_OnVBoxSVCAvailabilityChanged;
    84     eventSourceVirtualBoxClient.RegisterListener(m_mainEventListener, vboxClientEvents, TRUE);
     89    eventSourceVirtualBoxClient.RegisterListener(m_comEventListener, vboxClientEvents, TRUE);
    8590    AssertWrapperOk(eventSourceVirtualBoxClient);
    8691
     
    102107        << KVBoxEventType_OnSnapshotChanged
    103108        << KVBoxEventType_OnSnapshotRestored;
    104     eventSourceVirtualBox.RegisterListener(m_mainEventListener, vboxEvents, TRUE);
     109    eventSourceVirtualBox.RegisterListener(m_comEventListener, vboxEvents, TRUE);
    105110    AssertWrapperOk(eventSourceVirtualBox);
     111}
    106112
    107 
     113void UIVirtualBoxEventHandler::prepareConnections()
     114{
    108115    /* Create queued (async) connections for non-waitable signals: */
    109     connect(pListener->getWrapped(), SIGNAL(sigVBoxSVCAvailabilityChange(bool)),
     116    connect(m_pQtListener->getWrapped(), SIGNAL(sigVBoxSVCAvailabilityChange(bool)),
    110117            this, SIGNAL(sigVBoxSVCAvailabilityChange(bool)),
    111118            Qt::QueuedConnection);
    112     connect(pListener->getWrapped(), SIGNAL(sigMachineStateChange(QString, KMachineState)),
     119    connect(m_pQtListener->getWrapped(), SIGNAL(sigMachineStateChange(QString, KMachineState)),
    113120            this, SIGNAL(sigMachineStateChange(QString, KMachineState)),
    114121            Qt::QueuedConnection);
    115     connect(pListener->getWrapped(), SIGNAL(sigMachineDataChange(QString)),
     122    connect(m_pQtListener->getWrapped(), SIGNAL(sigMachineDataChange(QString)),
    116123            this, SIGNAL(sigMachineDataChange(QString)),
    117124            Qt::QueuedConnection);
    118     connect(pListener->getWrapped(), SIGNAL(sigMachineRegistered(QString, bool)),
     125    connect(m_pQtListener->getWrapped(), SIGNAL(sigMachineRegistered(QString, bool)),
    119126            this, SIGNAL(sigMachineRegistered(QString, bool)),
    120127            Qt::QueuedConnection);
    121     connect(pListener->getWrapped(), SIGNAL(sigSessionStateChange(QString, KSessionState)),
     128    connect(m_pQtListener->getWrapped(), SIGNAL(sigSessionStateChange(QString, KSessionState)),
    122129            this, SIGNAL(sigSessionStateChange(QString, KSessionState)),
    123130            Qt::QueuedConnection);
    124     connect(pListener->getWrapped(), SIGNAL(sigSnapshotTake(QString, QString)),
     131    connect(m_pQtListener->getWrapped(), SIGNAL(sigSnapshotTake(QString, QString)),
    125132            this, SIGNAL(sigSnapshotTake(QString, QString)),
    126133            Qt::QueuedConnection);
    127     connect(pListener->getWrapped(), SIGNAL(sigSnapshotDelete(QString, QString)),
     134    connect(m_pQtListener->getWrapped(), SIGNAL(sigSnapshotDelete(QString, QString)),
    128135            this, SIGNAL(sigSnapshotDelete(QString, QString)),
    129136            Qt::QueuedConnection);
    130     connect(pListener->getWrapped(), SIGNAL(sigSnapshotChange(QString, QString)),
     137    connect(m_pQtListener->getWrapped(), SIGNAL(sigSnapshotChange(QString, QString)),
    131138            this, SIGNAL(sigSnapshotChange(QString, QString)),
    132139            Qt::QueuedConnection);
    133     connect(pListener->getWrapped(), SIGNAL(sigSnapshotRestore(QString, QString)),
     140    connect(m_pQtListener->getWrapped(), SIGNAL(sigSnapshotRestore(QString, QString)),
    134141            this, SIGNAL(sigSnapshotRestore(QString, QString)),
    135142            Qt::QueuedConnection);
    136143}
    137144
    138 void UIVirtualBoxEventHandler::cleanup()
     145void UIVirtualBoxEventHandler::cleanupConnections()
     146{
     147    /* Nothing for now. */
     148}
     149
     150void UIVirtualBoxEventHandler::cleanupListener()
    139151{
    140152    /* Get VirtualBox: */
     
    145157    AssertWrapperOk(eventSourceVirtualBox);
    146158    /* Unregister listener: */
    147     eventSourceVirtualBox.UnregisterListener(m_mainEventListener);
     159    eventSourceVirtualBox.UnregisterListener(m_comEventListener);
    148160
    149161    /* Get VirtualBoxClient: */
     
    154166    AssertWrapperOk(eventSourceVirtualBoxClient);
    155167    /* Unregister listener: */
    156     eventSourceVirtualBoxClient.UnregisterListener(m_mainEventListener);
     168    eventSourceVirtualBoxClient.UnregisterListener(m_comEventListener);
    157169}
    158170
     171void UIVirtualBoxEventHandler::cleanup()
     172{
     173    /* Cleanup: */
     174    cleanupConnections();
     175    cleanupListener();
     176}
     177
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.h

    r60224 r60225  
    2121/* Qt includes: */
    2222#include <QObject>
     23
     24/* GUI includes: */
     25#include "UIMainEventListener.h"
    2326
    2427/* COM includes: */
     
    6972    ~UIVirtualBoxEventHandler();
    7073
    71     /** Prepares all. */
    72     void prepare();
    73     /** Cleanups all. */
    74     void cleanup();
     74    /** @name Prepare/Cleanup cascade.
     75      * @{ */
     76        /** Prepares all. */
     77        void prepare();
     78        /** Prepares listener. */
     79        void prepareListener();
     80        /** Prepares connections. */
     81        void prepareConnections();
     82
     83        /** Cleanups connections. */
     84        void cleanupConnections();
     85        /** Cleanups listener. */
     86        void cleanupListener();
     87        /** Cleanups all. */
     88        void cleanup();
     89    /** @} */
    7590
    7691private:
     
    7994    static UIVirtualBoxEventHandler *m_spInstance;
    8095
     96    /** Holds the Qt event listener instance. */
     97    ComObjPtr<UIMainEventListenerImpl> m_pQtListener;
    8198    /** Holds the COM event listener instance. */
    82     CEventListener m_mainEventListener;
     99    CEventListener m_comEventListener;
    83100};
    84101
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