Index: /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.mm
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.mm	(revision 30000)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.mm	(revision 30001)
@@ -20,4 +20,7 @@
 
 #include "VBoxUtils-darwin.h"
+#include "VBoxCocoaHelper.h"
+
+#include <QMenu>
 
 #include <iprt/assert.h>
@@ -29,5 +32,5 @@
 NativeWindowRef darwinToNativeWindowImpl (NativeViewRef aView)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    CocoaAutoreleasePool pool;
 
     NativeWindowRef window = NULL;
@@ -35,5 +38,4 @@
         window = [aView window];
 
-    [pool release];
     return window;
 }
@@ -41,5 +43,5 @@
 NativeViewRef darwinToNativeViewImpl (NativeWindowRef aWindow)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    CocoaAutoreleasePool pool;
 
     NativeViewRef view = NULL;
@@ -47,5 +49,4 @@
         view = [aWindow contentView];
 
-    [pool release];
     return view;
 }
@@ -53,23 +54,19 @@
 void darwinSetShowsToolbarButtonImpl (NativeWindowRef aWindow, bool aEnabled)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    CocoaAutoreleasePool pool;
 
     [aWindow setShowsToolbarButton:aEnabled];
-
-    [pool release];
 }
 
 void darwinSetShowsResizeIndicatorImpl (NativeWindowRef aWindow, bool aEnabled)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    CocoaAutoreleasePool pool;
 
     [aWindow setShowsResizeIndicator:aEnabled];
-
-    [pool release];
 }
 
 void darwinSetHidesAllTitleButtonsImpl (NativeWindowRef aWindow)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    CocoaAutoreleasePool pool;
 
     /* Remove all title buttons by changing the style mask. This method is
@@ -95,11 +92,9 @@
             [pButton setEnabled: NO];
     }
-
-    [pool release];
 }
 
 void darwinSetShowsWindowTransparentImpl (NativeWindowRef aWindow, bool aEnabled)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    CocoaAutoreleasePool pool;
 
     if (aEnabled)
@@ -115,6 +110,12 @@
         [aWindow setHasShadow:YES];
     }
+}
 
-    [pool release];
+void darwinSetDockIconMenu(QMenu* pMenu)
+{
+    CocoaAutoreleasePool pool;
+
+    extern void qt_mac_set_dock_menu(QMenu *);
+    qt_mac_set_dock_menu(pMenu);
 }
 
@@ -126,14 +127,12 @@
 void darwinSetMouseCoalescingEnabled (bool aEnabled)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    CocoaAutoreleasePool pool;
 
     [NSEvent setMouseCoalescingEnabled:aEnabled];
-
-    [pool release];
 }
 
 void darwinWindowAnimateResizeImpl (NativeWindowRef aWindow, int x, int y, int width, int height)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    CocoaAutoreleasePool pool;
 
     /* It seems that Qt doesn't return the height of the window with the
@@ -151,20 +150,16 @@
 
     [aWindow setFrame:windowFrame display:YES animate:YES];
-
-    [pool release];
 }
 
 void darwinWindowInvalidateShadowImpl (NativeWindowRef aWindow)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    CocoaAutoreleasePool pool;
 
     [aWindow invalidateShadow];
-
-    [pool release];
 }
 
 int darwinWindowToolBarHeight (NativeWindowRef aWindow)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    CocoaAutoreleasePool pool;
 
     NSToolbar *toolbar = [aWindow toolbar];
@@ -177,5 +172,4 @@
         toolbarHeight = NSHeight (windowFrame) - NSHeight ([[aWindow contentView] frame]) - theight;
 
-    [pool release];
     return toolbarHeight;
 }
@@ -183,9 +177,8 @@
 bool darwinIsWindowMaximized(NativeWindowRef aWindow)
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    CocoaAutoreleasePool pool;
 
     bool fResult = [aWindow isZoomed];
 
-    [pool release];
     return fResult;
 }
@@ -193,9 +186,8 @@
 float darwinSmallFontSize()
 {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    CocoaAutoreleasePool pool;
 
     float size = [NSFont systemFontSizeForControlSize: NSSmallControlSize];
 
-    [pool release];
     return size;
 }
Index: /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.h	(revision 30000)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.h	(revision 30001)
@@ -43,4 +43,5 @@
 class QPixmap;
 class QImage;
+class QMenu;
 
 # ifdef QT_MAC_USE_COCOA
@@ -154,4 +155,5 @@
 void darwinSetHidesAllTitleButtons(QWidget *aWidget);
 void darwinSetShowsWindowTransparent(QWidget *aWidget, bool aEnabled);
+void darwinSetDockIconMenu(QMenu *pMenu);
 void darwinDisableIconsInMenus(void);
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp	(revision 30000)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp	(revision 30001)
@@ -598,6 +598,5 @@
 
     /* Add it to the dock. */
-    extern void qt_mac_set_dock_menu(QMenu *);
-    qt_mac_set_dock_menu(pDockMenu);
+    ::darwinSetDockIconMenu(pDockMenu);
 
     /* Now the dock icon preview */
