Index: /trunk/src/VBox/Main/include/ConsoleImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 39710)
+++ /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 39711)
@@ -790,4 +790,8 @@
     ComObjPtr<Progress> mptrCancelableProgress;
 
+    /* The purpose of caching of some events is probably in order to
+       automatically fire them at new event listeners.  However, there is no
+       (longer?) any code making use of this... */
+#ifdef CONSOLE_WITH_EVENT_CACHE
     struct
     {
@@ -803,6 +807,5 @@
             uint32_t height;
             com::SafeArray<BYTE> shape;
-        }
-        mpsc;
+        } mpsc;
 
         /** OnMouseCapabilityChange() cache */
@@ -813,6 +816,5 @@
             BOOL supportsRelative;
             BOOL needsHostCursor;
-        }
-        mcc;
+        } mcc;
 
         /** OnKeyboardLedsChange() cache */
@@ -823,18 +825,18 @@
             bool capsLock;
             bool scrollLock;
-        }
-        klc;
+        } klc;
 
         void clear()
         {
-            /* We cannot do memset() on mpsc to avoid cleaning shape's vtable */
+            RT_ZERO(mcc);
+            RT_ZERO(klc);
+
+            /* We cannot RT_ZERO mpsc because of shape's vtable. */
             mpsc.shape.setNull();
             mpsc.valid = mpsc.visible = mpsc.alpha = false;
             mpsc.xHot = mpsc.yHot = mpsc.width = mpsc.height = 0;
-            ::memset(&mcc, 0, sizeof mcc);
-            ::memset(&klc, 0, sizeof klc);
         }
-    }
-    mCallbackData;
+    } mCallbackData;
+#endif
     ComPtr<IEventListener> mVmListener;
 
Index: /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 39710)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 39711)
@@ -699,5 +699,7 @@
     unconst(mEventSource).setNull();
 
+#ifdef CONSOLE_WITH_EVENT_CACHE
     mCallbackData.clear();
+#endif
 
     LogFlowThisFuncLeave();
@@ -5700,4 +5702,7 @@
     AssertComRCReturnVoid(autoCaller.rc());
 
+#ifndef CONSOLE_WITH_EVENT_CACHE
+    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+#else
     /* We need a write lock because we alter the cached callback data */
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -5721,4 +5726,5 @@
         mCallbackData.mpsc.shape.resize(0);
     mCallbackData.mpsc.valid = true;
+#endif
 
     fireMousePointerShapeChangedEvent(mEventSource, fVisible, fAlpha, xHot, yHot, width, height, ComSafeArrayInArg(pShape));
@@ -5740,4 +5746,7 @@
     AssertComRCReturnVoid(autoCaller.rc());
 
+#ifndef CONSOLE_WITH_EVENT_CACHE
+    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+#else
     /* We need a write lock because we alter the cached callback data */
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -5748,4 +5757,5 @@
     mCallbackData.mcc.needsHostCursor = needsHostCursor;
     mCallbackData.mcc.valid = true;
+#endif
 
     fireMouseCapabilityChangedEvent(mEventSource, supportsAbsolute, supportsRelative, needsHostCursor);
@@ -5800,4 +5810,7 @@
     AssertComRCReturnVoid(autoCaller.rc());
 
+#ifndef CONSOLE_WITH_EVENT_CACHE
+    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+#else
     /* We need a write lock because we alter the cached callback data */
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -5808,4 +5821,5 @@
     mCallbackData.klc.scrollLock = fScrollLock;
     mCallbackData.klc.valid = true;
+#endif
 
     fireKeyboardLedsChangedEvent(mEventSource, fNumLock, fCapsLock, fScrollLock);
@@ -6925,6 +6939,8 @@
         mVMDestroying = false;
 
+#ifdef CONSOLE_WITH_EVENT_CACHE
     if (SUCCEEDED(rc))
         mCallbackData.clear();
+#endif
 
     LogFlowThisFuncLeave();
