Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.cpp	(revision 31317)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.cpp	(revision 31318)
@@ -184,9 +184,9 @@
         {
             CGImageRef pauseImg = ::darwinToCGImageRef(&m_pMachineView->pauseShot());
-            subImage = CGImageCreateWithImageInRect(pauseImg, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
+            subImage = CGImageCreateWithImageInRect(pauseImg, CGRectMake(m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
             CGImageRelease(pauseImg);
         }
         else
-            subImage = CGImageCreateWithImageInRect(m_image, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
+            subImage = CGImageCreateWithImageInRect(m_image, CGRectMake(m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
         Assert(VALID_PTR(subImage));
         /* Clear the background (Make the rect fully transparent) */
@@ -247,5 +247,5 @@
          * of the bounding box of the current paint event */
         CGRect ir = ::darwinToCGRect(aEvent->rect());
-        CGRect is = CGRectMake(CGRectGetMinX(ir) + m_pMachineView->contentsX(), CGRectGetMinY(ir) + m_pMachineView->contentsY(), CGRectGetWidth(ir), CGRectGetHeight(ir));
+        CGRect is = CGRectMake(CGRectGetMinX(ir), CGRectGetMinY(ir), CGRectGetWidth(ir), CGRectGetHeight(ir));
 
         double iw = 1.0;
@@ -275,15 +275,18 @@
             is.size.height = (int)(is.size.height * ih) + 2;
             /* Make sure the size is within the image boundaries */
-            is = CGRectIntersection(is, CGRectMake(0, 0, CGImageGetWidth(m_image), CGImageGetHeight(m_image)));
+            CGRect is1 = CGRectIntersection(is, CGRectMake(0, 0, CGImageGetWidth(m_image), CGImageGetHeight(m_image)));
             /* Cause we probably changed the rectangle to update in the origin
              * coordinate system, we have to recalculate the update rectangle
              * for the screen coordinates as well. Please note that this has to
              * be in double precision. */
-            ir.origin.x = is.origin.x / iw;
-            ir.origin.y = is.origin.y / ih;
-            ir.size.width = is.size.width / iw;
-            ir.size.height = is.size.height / ih;
-            /* Create the sub image */
-            subImage = CGImageCreateWithImageInRect(m_image, is);
+            ir.origin.x = is1.origin.x / iw;
+            ir.origin.y = is1.origin.y / ih;
+            ir.size.width = is1.size.width / iw;
+            ir.size.height = is1.size.height / ih;
+            /* Create the sub image. Note: The copy step is necessary otherwise
+             * strange things happens especially on Snow Leopard. No idea why. */
+            CGImageRef tmpImage = CGImageCreateWithImageInRect(m_image, is1);
+            subImage = CGImageCreateCopy(tmpImage);
+            CGImageRelease(tmpImage);
         }
         if (subImage)
@@ -306,5 +309,4 @@
             CGContextSetInterpolationQuality(ctx, kCGInterpolationHigh);
             /* Draw the image. */
-
             CGContextDrawImage(ctx, ::darwinFlipCGRect(ir, CGRectGetHeight(viewRect)), subImage);
             CGImageRelease(subImage);
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp	(revision 31317)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp	(revision 31318)
@@ -197,8 +197,8 @@
              * catch all rounding errors. (use 1 time the ratio factor and
              * round down on top/left, but round up for the width/height) */
-            viewport()->repaint((int)(pPaintEvent->x() * xRatio) - ((int)xRatio),
-                                (int)(pPaintEvent->y() * yRatio) - ((int)yRatio),
-                                (int)(pPaintEvent->width() * xRatio) + ((int)xRatio + 1) * 2,
-                                (int)(pPaintEvent->height() * yRatio) + ((int)yRatio + 1) * 2);
+            viewport()->repaint((int)(pPaintEvent->x() * xRatio) - ((int)xRatio) - 1,
+                                (int)(pPaintEvent->y() * yRatio) - ((int)yRatio) - 1,
+                                (int)(pPaintEvent->width() * xRatio) + ((int)xRatio + 2) * 2,
+                                (int)(pPaintEvent->height() * yRatio) + ((int)yRatio + 2) * 2);
             pEvent->accept();
             return true;
