Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.cpp	(revision 54130)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.cpp	(revision 54131)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2010-2012 Oracle Corporation
+ * Copyright (C) 2010-2015 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -38,5 +38,5 @@
 {
     if (!m_pInstance)
-        m_pInstance = new UIVirtualBoxEventHandler();
+        m_pInstance = new UIVirtualBoxEventHandler;
     return m_pInstance;
 }
@@ -54,10 +54,17 @@
 UIVirtualBoxEventHandler::UIVirtualBoxEventHandler()
 {
-//    RTPrintf("Self add: %RTthrd\n", RTThreadSelf());
-    const CVirtualBox &vbox = vboxGlobal().virtualBox();
+    /* Create Main-event listener instance: */
     ComObjPtr<UIMainEventListenerImpl> pListener;
     pListener.createObject();
-    pListener->init(new UIMainEventListener(), this);
+    pListener->init(new UIMainEventListener, this);
     m_mainEventListener = CEventListener(pListener);
+
+    /* Get VirtualBox: */
+    const CVirtualBox vbox = vboxGlobal().virtualBox();
+    AssertWrapperOk(vbox);
+    /* Get event-source: */
+    CEventSource eventSource = vbox.GetEventSource();
+    AssertWrapperOk(eventSource);
+    /* Register listener for expected event-types: */
     QVector<KVBoxEventType> events;
     events
@@ -69,32 +76,26 @@
         << KVBoxEventType_OnSnapshotDeleted
         << KVBoxEventType_OnSnapshotChanged;
+    eventSource.RegisterListener(m_mainEventListener, events, TRUE);
+    AssertWrapperOk(eventSource);
 
-    vbox.GetEventSource().RegisterListener(m_mainEventListener, events, TRUE);
-    AssertWrapperOk(vbox);
-
+    /* Prepare connections: */
     connect(pListener->getWrapped(), SIGNAL(sigMachineStateChange(QString, KMachineState)),
             this, SIGNAL(sigMachineStateChange(QString, KMachineState)),
             Qt::QueuedConnection);
-
     connect(pListener->getWrapped(), SIGNAL(sigMachineDataChange(QString)),
             this, SIGNAL(sigMachineDataChange(QString)),
             Qt::QueuedConnection);
-
     connect(pListener->getWrapped(), SIGNAL(sigMachineRegistered(QString, bool)),
             this, SIGNAL(sigMachineRegistered(QString, bool)),
             Qt::QueuedConnection);
-
     connect(pListener->getWrapped(), SIGNAL(sigSessionStateChange(QString, KSessionState)),
             this, SIGNAL(sigSessionStateChange(QString, KSessionState)),
             Qt::QueuedConnection);
-
     connect(pListener->getWrapped(), SIGNAL(sigSnapshotTake(QString, QString)),
             this, SIGNAL(sigSnapshotTake(QString, QString)),
             Qt::QueuedConnection);
-
     connect(pListener->getWrapped(), SIGNAL(sigSnapshotDelete(QString, QString)),
             this, SIGNAL(sigSnapshotDelete(QString, QString)),
             Qt::QueuedConnection);
-
     connect(pListener->getWrapped(), SIGNAL(sigSnapshotChange(QString, QString)),
             this, SIGNAL(sigSnapshotChange(QString, QString)),
@@ -104,5 +105,12 @@
 UIVirtualBoxEventHandler::~UIVirtualBoxEventHandler()
 {
-    const CVirtualBox &vbox = vboxGlobal().virtualBox();
-    vbox.GetEventSource().UnregisterListener(m_mainEventListener);
+    /* Get VirtualBox: */
+    const CVirtualBox vbox = vboxGlobal().virtualBox();
+    AssertWrapperOk(vbox);
+    /* Get event-source: */
+    CEventSource eventSource = vbox.GetEventSource();
+    AssertWrapperOk(eventSource);
+    /* Unregister listener: */
+    eventSource.UnregisterListener(m_mainEventListener);
 }
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.h	(revision 54130)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.h	(revision 54131)
@@ -4,5 +4,5 @@
 
 /*
- * Copyright (C) 2010-2012 Oracle Corporation
+ * Copyright (C) 2010-2015 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -15,6 +15,6 @@
  */
 
-#ifndef __UIVirtualBoxEventHandler_h__
-#define __UIVirtualBoxEventHandler_h__
+#ifndef ___UIVirtualBoxEventHandler_h___
+#define ___UIVirtualBoxEventHandler_h___
 
 /* COM includes: */
@@ -22,28 +22,43 @@
 #include "CEventListener.h"
 
-class UIVirtualBoxEventHandler: public QObject
+/** Active event handler singleton for the CVirtualBox event-source. */
+class UIVirtualBoxEventHandler : public QObject
 {
     Q_OBJECT;
 
+signals:
+
+    /** Notifies listeners about @a state change event for the machine with @a strId. */
+    void sigMachineStateChange(QString strId, KMachineState state);
+    /** Notifies listeners about data change event for the machine with @a strId. */
+    void sigMachineDataChange(QString strId);
+    /** Notifies listeners about machine with @a strId was @a fRegistered. */
+    void sigMachineRegistered(QString strId, bool fRegistered);
+    /** Notifies listeners about @a state change event for the session of the machine with @a strId. */
+    void sigSessionStateChange(QString strId, KSessionState state);
+    /** Notifies listeners about snapshot with @a strSnapshotId was taken for the machine with @a strId. */
+    void sigSnapshotTake(QString strId, QString strSnapshotId);
+    /** Notifies listeners about snapshot with @a strSnapshotId was deleted for the machine with @a strId. */
+    void sigSnapshotDelete(QString strId, QString strSnapshotId);
+    /** Notifies listeners about snapshot with @a strSnapshotId was changed for the machine with @a strId. */
+    void sigSnapshotChange(QString strId, QString strSnapshotId);
+
 public:
+
+    /** Returns singleton instance created by the factory. */
     static UIVirtualBoxEventHandler* instance();
+    /** Destroys singleton instance created by the factory. */
     static void destroy();
 
-signals:
-    /* VirtualBox main signals */
-    void sigMachineStateChange(QString strId, KMachineState state);
-    void sigMachineDataChange(QString strId);
-    void sigMachineRegistered(QString strId, bool fRegistered);
-    void sigSessionStateChange(QString strId, KSessionState state);
-    void sigSnapshotTake(QString strId, QString strSnapshotId);
-    void sigSnapshotDelete(QString strId, QString strSnapshotId);
-    void sigSnapshotChange(QString strId, QString strSnapshotId);
+private:
 
-private:
+    /** Constructor. */
     UIVirtualBoxEventHandler();
+    /** Destructor. */
     ~UIVirtualBoxEventHandler();
 
-    /* Private member vars */
+    /** Holds the static singleton instance. */
     static UIVirtualBoxEventHandler *m_pInstance;
+    /** Holds the COM event-listener instance. */
     CEventListener m_mainEventListener;
 };
@@ -51,4 +66,3 @@
 #define gVBoxEvents UIVirtualBoxEventHandler::instance()
 
-#endif /* !__UIVirtualBoxEventHandler_h__ */
-
+#endif /* !___UIVirtualBoxEventHandler_h___ */
