Index: trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 17160)
+++ trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 17175)
@@ -151,5 +151,5 @@
 VirtualBox_DEFS           = VBOX_GUI_SEPARATE_VM_PROCESS
 VirtualBox_DEFS.debug     = VBOX_CHECK_STATE # QT_FATAL_ASSERT
-VirtualBox_DEFS.darwin    = VBOX_GUI_USE_QIMAGE VBOX_WITHOUT_QHTTP
+VirtualBox_DEFS.darwin    = VBOX_GUI_USE_QUARTZ2D VBOX_GUI_USE_QIMAGE VBOX_WITHOUT_QHTTP
 ifndef VBOX_WITH_COCOA_QT
 VirtualBox_DEFS.darwin.x86= VBOX_GUI_USE_QUARTZ2D USE_HID_FOR_MODIFIERS
Index: trunk/src/VBox/Frontends/VirtualBox/include/VBoxDockIconPreview.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/include/VBoxDockIconPreview.h	(revision 17160)
+++ trunk/src/VBox/Frontends/VirtualBox/include/VBoxDockIconPreview.h	(revision 17175)
@@ -27,4 +27,5 @@
 
 #ifdef QT_MAC_USE_COCOA
+# include <ApplicationServices/ApplicationServices.h>
 /** @todo include chocolatey headers... */
 #else
@@ -44,13 +45,13 @@
 
     void updateDockOverlay();
-#ifndef QT_MAC_USE_COCOA
+//#ifndef QT_MAC_USE_COCOA
     void updateDockPreview (CGImageRef aVMImage);
-#endif
+//#endif
     void updateDockPreview (VBoxFrameBuffer *aFrameBuffer);
 
 private:
-#ifdef QT_MAC_USE_COCOA
+//#ifdef QT_MAC_USE_COCOA
     /** @todo Carbon -> Cocoa */
-#else
+//#else
     inline void initPreviewImages();
     inline void initOverlayData (int aBitmapByteCount);
@@ -67,11 +68,11 @@
         return aRect;
     }
-#endif /* !QT_MAC_USE_COCOA */
+//#endif /* !QT_MAC_USE_COCOA */
 
     /* Private member vars */
     VBoxConsoleWnd *mMainWnd;
-#ifdef QT_MAC_USE_COCOA
+//#ifdef QT_MAC_USE_COCOA
     /** @todo Carbon -> Cocoa */
-#else
+//#else
     const CGRect mDockIconRect;
 
@@ -88,5 +89,5 @@
     CGRect mUpdateRect;
     CGRect mMonitorRect;
-#endif
+//#endif
 };
 
Index: trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils-darwin.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils-darwin.h	(revision 17160)
+++ trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils-darwin.h	(revision 17175)
@@ -151,9 +151,4 @@
 class QImage;
 
-# ifndef QT_MAC_USE_COCOA
-
-/* Asserts if a != noErr and prints the error code */
-#  define AssertCarbonOSStatus(a) AssertMsg ((a) == noErr, ("Carbon OSStatus: %d\n", static_cast<int> (a)))
-
 /* Converting stuff */
 CGImageRef darwinToCGImageRef (const QImage *aImage);
@@ -171,4 +166,10 @@
     return static_cast<CGContext *> (aWidget->macCGHandle());
 }
+
+# ifndef QT_MAC_USE_COCOA
+
+/* Asserts if a != noErr and prints the error code */
+#  define AssertCarbonOSStatus(a) AssertMsg ((a) == noErr, ("Carbon OSStatus: %d\n", static_cast<int> (a)))
+
 
 /**
Index: trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp	(revision 17160)
+++ trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp	(revision 17175)
@@ -3031,5 +3031,7 @@
          * an repaint only. All the magic clipping stuff is done
          * in the paint engine. */
+#ifndef QT_MAC_USE_COCOA
         HIViewReshapeStructure (::darwinToNativeView (console->viewport()));
+#endif /* QT_MAC_USE_COCOA */
 //        HIWindowInvalidateShadow (::darwinToWindowRef (console->viewport()));
 //        ReshapeCustomWindow (::darwinToWindowRef (this));
Index: trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQuartz2D.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQuartz2D.cpp	(revision 17160)
+++ trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQuartz2D.cpp	(revision 17175)
@@ -159,4 +159,5 @@
     Assert (mImage);
 
+#ifndef QT_MAC_USE_COCOA
     VBoxConsoleWnd *main = qobject_cast <VBoxConsoleWnd *> (vboxGlobal().mainWindow());
     Assert (VALID_PTR (main));
@@ -252,4 +253,5 @@
         HIViewDrawCGImage (ctx, &destRect, subImage);
     }
+#endif /* QT_MAC_USE_COCOA */
 }
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxDockIconPreview.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxDockIconPreview.cpp	(revision 17160)
+++ trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxDockIconPreview.cpp	(revision 17175)
@@ -32,5 +32,5 @@
 #endif
 
-#ifndef QT_MAC_USE_COCOA
+//#ifndef QT_MAC_USE_COCOA
 /* Import private function to capture the window content of any given window. */
 CG_EXTERN_C_BEGIN
@@ -41,10 +41,10 @@
 CG_EXTERN void CGContextCopyWindowCaptureContentsToRect(CGContextRef c, CGRect dstRect, CGSConnectionID connection, CGSWindowID window, int zero);
 CG_EXTERN_C_END
-#endif /* !QT_MAC_USE_COCOA */
+//#endif /* !QT_MAC_USE_COCOA */
 
 VBoxDockIconPreview::VBoxDockIconPreview (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage)
     :  mMainWnd (aMainWnd)
-#ifdef QT_MAC_USE_COCOA
-#else
+//#ifdef QT_MAC_USE_COCOA
+//#else
      , mDockIconRect (CGRectMake (0, 0, 128, 128))
      , mDockMonitor (NULL)
@@ -53,5 +53,5 @@
      , mUpdateRect (CGRectMake (0, 0, 0, 0))
      , mMonitorRect (CGRectMake (0, 0, 0, 0))
-#endif
+//#endif
 {
 #ifdef QT_MAC_USE_COCOA
@@ -88,5 +88,5 @@
 }
 
-#ifndef QT_MAC_USE_COCOA
+//#ifndef QT_MAC_USE_COCOA
 
 void VBoxDockIconPreview::initPreviewImages()
@@ -158,5 +158,5 @@
 }
 
-#endif /* !QT_MAC_USE_COCOA */
+//#endif /* !QT_MAC_USE_COCOA */
 
 void VBoxDockIconPreview::updateDockOverlay()
@@ -208,5 +208,5 @@
 }
 
-#ifndef QT_MAC_USE_COCOA
+//#ifndef QT_MAC_USE_COCOA
 void VBoxDockIconPreview::updateDockPreview (CGImageRef aVMImage)
 {
@@ -251,4 +251,5 @@
     CGContextDrawImage (context, flipRect (iconRect), aVMImage);
 
+#ifndef QT_MAC_USE_COCOA
     /* Process the content of any external OpenGL window. */
     WindowRef w = darwinToNativeWindow (mMainWnd);
@@ -293,4 +294,5 @@
         }
     }
+#endif /* QT_MAC_USE_COCOA */
 
     /* Draw the glossy overlay */
@@ -306,10 +308,10 @@
     CGColorSpaceRelease (cs);
 }
-#endif /* !QT_MAC_USE_COCOA */
+//#endif /* !QT_MAC_USE_COCOA */
 
 void VBoxDockIconPreview::updateDockPreview (VBoxFrameBuffer *aFrameBuffer)
 {
-#ifdef QT_MAC_USE_COCOA
-#else  /* !QT_MAC_USE_COCOA */
+//#ifdef QT_MAC_USE_COCOA
+//#else  /* !QT_MAC_USE_COCOA */
     CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
     Assert (cs);
@@ -329,5 +331,5 @@
     CGDataProviderRelease (dp);
     CGColorSpaceRelease (cs);
-#endif /* !QT_MAC_USE_COCOA */
-}
-
+//#endif /* !QT_MAC_USE_COCOA */
+}
+
Index: trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-carbon.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-carbon.cpp	(revision 17160)
+++ trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-carbon.cpp	(revision 17175)
@@ -85,56 +85,4 @@
     QImage *qimg = (QImage *)info;
     delete qimg;
-}
-
-/**
- * Converts a QPixmap to a CGImage.
- *
- * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
- * @param   aPixmap     Pointer to the QPixmap instance to convert.
- */
-CGImageRef darwinToCGImageRef (const QImage *aImage)
-{
-    QImage *imageCopy = new QImage (*aImage);
-    /** @todo this code assumes 32-bit image input, the lazy bird convert image to 32-bit method is anything but optimal... */
-    if (imageCopy->format() != QImage::Format_ARGB32)
-        *imageCopy = imageCopy->convertToFormat (QImage::Format_ARGB32);
-    Assert (!imageCopy->isNull());
-
-    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
-    CGDataProviderRef dp = CGDataProviderCreateWithData (imageCopy, aImage->bits(), aImage->numBytes(), darwinDataProviderReleaseQImage);
-
-    CGBitmapInfo bmpInfo = kCGImageAlphaFirst | kCGBitmapByteOrder32Host;
-    CGImageRef ir = CGImageCreate (imageCopy->width(), imageCopy->height(), 8, 32, imageCopy->bytesPerLine(), cs,
-                                   bmpInfo, dp, 0 /*decode */, 0 /* shouldInterpolate */,
-                                   kCGRenderingIntentDefault);
-    CGColorSpaceRelease (cs);
-    CGDataProviderRelease (dp);
-
-    Assert (ir);
-    return ir;
-}
-
-/**
- * Converts a QPixmap to a CGImage.
- *
- * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
- * @param   aPixmap     Pointer to the QPixmap instance to convert.
- */
-CGImageRef darwinToCGImageRef (const QPixmap *aPixmap)
-{
-    return aPixmap->toMacCGImageRef();
-}
-
-/**
- * Loads an image using Qt and converts it to a CGImage.
- *
- * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
- * @param   aSource     The source name.
- */
-CGImageRef darwinToCGImageRef (const char *aSource)
-{
-    QPixmap qpm (QString(":/") + aSource);
-    Assert (!qpm.isNull());
-    return ::darwinToCGImageRef (&qpm);
 }
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.cpp	(revision 17160)
+++ trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.cpp	(revision 17175)
@@ -21,4 +21,6 @@
 
 #include "VBoxUtils-darwin.h"
+
+#include <iprt/assert.h>
 
 #include <QApplication>
@@ -126,4 +128,68 @@
     painter.end();
     return dragPixmap;
+}
+
+/**
+ * Callback for deleting the QImage object when CGImageCreate is done
+ * with it (which is probably not until the returned CFGImageRef is released).
+ *
+ * @param   info        Pointer to the QImage.
+ */
+static void darwinDataProviderReleaseQImage (void *info, const void *, size_t)
+{
+    QImage *qimg = (QImage *)info;
+    delete qimg;
+}
+
+/**
+ * Converts a QPixmap to a CGImage.
+ *
+ * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
+ * @param   aPixmap     Pointer to the QPixmap instance to convert.
+ */
+CGImageRef darwinToCGImageRef (const QImage *aImage)
+{
+    QImage *imageCopy = new QImage (*aImage);
+    /** @todo this code assumes 32-bit image input, the lazy bird convert image to 32-bit method is anything but optimal... */
+    if (imageCopy->format() != QImage::Format_ARGB32)
+        *imageCopy = imageCopy->convertToFormat (QImage::Format_ARGB32);
+    Assert (!imageCopy->isNull());
+
+    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
+    CGDataProviderRef dp = CGDataProviderCreateWithData (imageCopy, aImage->bits(), aImage->numBytes(), darwinDataProviderReleaseQImage);
+
+    CGBitmapInfo bmpInfo = kCGImageAlphaFirst | kCGBitmapByteOrder32Host;
+    CGImageRef ir = CGImageCreate (imageCopy->width(), imageCopy->height(), 8, 32, imageCopy->bytesPerLine(), cs,
+                                   bmpInfo, dp, 0 /*decode */, 0 /* shouldInterpolate */,
+                                   kCGRenderingIntentDefault);
+    CGColorSpaceRelease (cs);
+    CGDataProviderRelease (dp);
+
+    Assert (ir);
+    return ir;
+}
+
+/**
+ * Converts a QPixmap to a CGImage.
+ *
+ * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
+ * @param   aPixmap     Pointer to the QPixmap instance to convert.
+ */
+CGImageRef darwinToCGImageRef (const QPixmap *aPixmap)
+{
+    return aPixmap->toMacCGImageRef();
+}
+
+/**
+ * Loads an image using Qt and converts it to a CGImage.
+ *
+ * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
+ * @param   aSource     The source name.
+ */
+CGImageRef darwinToCGImageRef (const char *aSource)
+{
+    QPixmap qpm (QString(":/") + aSource);
+    Assert (!qpm.isNull());
+    return ::darwinToCGImageRef (&qpm);
 }
 
