Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp	(revision 29772)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp	(revision 29773)
@@ -643,8 +643,4 @@
     /* Setup focus policy: */
     setFocusPolicy(Qt::WheelFocus);
-
-#if defined Q_WS_WIN
-    gView = this;
-#endif
 
 #if defined Q_WS_PM
@@ -1178,4 +1174,5 @@
             case QEvent::WindowActivate:
             {
+                gView = this;
                 gKbdHook = SetWindowsHookEx(WH_KEYBOARD_LL, lowLevelKeyboardProc, GetModuleHandle(NULL), 0);
                 AssertMsg(gKbdHook, ("SetWindowsHookEx(): err=%d", GetLastError()));
@@ -1188,4 +1185,6 @@
                     UnhookWindowsHookEx(gKbdHook);
                     gKbdHook = NULL;
+                    if (gView == this)
+                        gView = 0;
                 }
                 break;
