Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp	(revision 22674)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp	(revision 22675)
@@ -2889,5 +2889,6 @@
                              new VBoxRepaintEvent (aX, aY, aW, aH));
 #else
-    vboxWidget()->postCmd(VBOXVHWA_PIPECMD_PAINT, &QRect(aX, aY, aW, aH));
+    QRect r(aX, aY, aW, aH);
+    vboxWidget()->postCmd(VBOXVHWA_PIPECMD_PAINT, &r);
 #endif
     return S_OK;
@@ -2949,4 +2950,7 @@
 VBoxGLWidget::VBoxGLWidget (VBoxConsoleView *aView, QWidget *aParent)
     : QGLWidget (VBoxGLWidget::vboxGLFormat(), aParent),
+    mSurfHandleTable(128), /* 128 should be enough */
+    mpfnOp(NULL),
+    mOpContext(NULL),
     mPixelFormat(0),
     mUsesGuestVRAM(false),
@@ -2954,7 +2958,5 @@
     mView(aView),
     mConstructingList(NULL),
-    mcRemaining2Contruct(0),
-    mpfnOp(NULL),
-    mSurfHandleTable(128) /* 128 should be enough */
+    mcRemaining2Contruct(0)
 {
     cmdPipeInit();
@@ -3169,4 +3171,5 @@
 void VBoxGLWidget::vboxDoProcessVHWACommands(void *pContext)
 {
+    Q_UNUSED(pContext);
     VBoxVHWACommandElement * pFirst = detachCmdList(NULL, NULL);
     do
@@ -3215,5 +3218,5 @@
     vboxDoVHWACmdExec(cmd);
 
-    delete cmd;
+    free(cmd);
 }
 
@@ -3472,11 +3475,13 @@
         if(pCmd->SurfInfo.PixelFormat.flags & VBOXVHWA_PF_RGB)
         {
-        	VBoxVHWAColorFormat format(pCmd->SurfInfo.PixelFormat.c.rgbBitCount,
+            VBoxVHWAColorFormat format(pCmd->SurfInfo.PixelFormat.c.rgbBitCount,
         	                                pCmd->SurfInfo.PixelFormat.m1.rgbRBitMask,
         	                                pCmd->SurfInfo.PixelFormat.m2.rgbGBitMask,
         	                                pCmd->SurfInfo.PixelFormat.m3.rgbBBitMask);
-            surf = new VBoxVHWASurfaceBase(this, &QSize(pCmd->SurfInfo.width, pCmd->SurfInfo.height),
-//                        ((pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OVERLAY) ? mDisplay.getPrimary()->rect().size() : &QSize(pCmd->SurfInfo.width, pCmd->SurfInfo.height)),
-                        &mDisplay.getPrimary()->rect().size(),
+            QSize surfSize(pCmd->SurfInfo.width, pCmd->SurfInfo.height);
+            QSize primarySize = mDisplay.getPrimary()->rect().size();
+            surf = new VBoxVHWASurfaceBase(this, &surfSize,
+//                        ((pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OVERLAY) ? mDisplay.getPrimary()->rect().size() : &surfSize),
+                        &primarySize,
                         format,
                         pSrcBltCKey, pDstBltCKey, pSrcOverlayCKey, pDstOverlayCKey,
@@ -3485,8 +3490,11 @@
         else if(pCmd->SurfInfo.PixelFormat.flags & VBOXVHWA_PF_FOURCC)
         {
+            QSize surfSize(pCmd->SurfInfo.width, pCmd->SurfInfo.height);
+            QSize primarySize = mDisplay.getPrimary()->rect().size();
+
             VBoxVHWAColorFormat format(pCmd->SurfInfo.PixelFormat.fourCC);
-            surf = new VBoxVHWASurfaceBase(this, &QSize(pCmd->SurfInfo.width, pCmd->SurfInfo.height),
+            surf = new VBoxVHWASurfaceBase(this, &surfSize,
             //                        ((pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OVERLAY) ? mDisplay.getPrimary()->rect().size() : &QSize(pCmd->SurfInfo.width, pCmd->SurfInfo.height)),
-                                    &mDisplay.getPrimary()->rect().size(),
+                                    &primarySize,
                                     format,
                                     pSrcBltCKey, pDstBltCKey, pSrcOverlayCKey, pDstOverlayCKey,
@@ -3657,4 +3665,5 @@
 {
     /**/
+    Q_UNUSED(pCmd);
     return VERR_NOT_IMPLEMENTED;
 //    VBoxVHWASurfaceBase *pDstSurf = (VBoxVHWASurfaceBase*)pCmd->u.in.hDstSurf;
@@ -3754,5 +3763,6 @@
          * i.e.
          * 1. indicate the value is overridden (no matter what we write here, bu it should be not NULL)*/
-        pSrcSurf->setOverriddenDstOverlayCKey(&VBoxVHWAColorKey(0, 0));
+        VBoxVHWAColorKey dummyCKey(0, 0);
+        pSrcSurf->setOverriddenDstOverlayCKey(&dummyCKey);
         /* tell the ckey is disabled */
         pSrcSurf->setDefaultDstOverlayCKey(NULL);
@@ -3767,5 +3777,6 @@
     {
         VBOXQGLLOG((", KEYSRCOVERRIDE"));
-        pSrcSurf->setOverriddenSrcOverlayCKey(&VBoxVHWAColorKey(pCmd->u.in.desc.SrcCK.high, pCmd->u.in.desc.SrcCK.low));
+        VBoxVHWAColorKey ckey(pCmd->u.in.desc.SrcCK.high, pCmd->u.in.desc.SrcCK.low);
+        pSrcSurf->setOverriddenSrcOverlayCKey(&ckey);
     }
     else
@@ -3879,9 +3890,11 @@
     const SurfList & surfaces = pList->surfaces();
 
+    QPoint pos(pCmd->u.in.xPos, pCmd->u.in.yPos);
+
     for (SurfList::const_iterator it = surfaces.begin();
              it != surfaces.end(); ++ it)
     {
         VBoxVHWASurfaceBase *pCurSrcSurf = (*it);
-        pCurSrcSurf->setTargetRectPosition(pDstSurf, &QPoint(pCmd->u.in.xPos, pCmd->u.in.yPos));;
+        pCurSrcSurf->setTargetRectPosition(pDstSurf, &pos);
     }
 
@@ -3900,17 +3913,21 @@
     if(pCmd->u.in.flags & VBOXVHWA_CKEY_DESTBLT)
     {
-        pSurf->setDstBltCKey(&VBoxVHWAColorKey(pCmd->u.in.CKey.high, pCmd->u.in.CKey.low));
+        VBoxVHWAColorKey ckey(pCmd->u.in.CKey.high, pCmd->u.in.CKey.low);
+        pSurf->setDstBltCKey(&ckey);
     }
     if(pCmd->u.in.flags & VBOXVHWA_CKEY_DESTOVERLAY)
     {
-        pSurf->setDefaultDstOverlayCKey(&VBoxVHWAColorKey(pCmd->u.in.CKey.high, pCmd->u.in.CKey.low));
+        VBoxVHWAColorKey ckey(pCmd->u.in.CKey.high, pCmd->u.in.CKey.low);
+        pSurf->setDefaultDstOverlayCKey(&ckey);
     }
     if(pCmd->u.in.flags & VBOXVHWA_CKEY_SRCBLT)
     {
-        pSurf->setSrcBltCKey(&VBoxVHWAColorKey(pCmd->u.in.CKey.high, pCmd->u.in.CKey.low));
+        VBoxVHWAColorKey ckey(pCmd->u.in.CKey.high, pCmd->u.in.CKey.low);
+        pSurf->setSrcBltCKey(&ckey);
     }
     if(pCmd->u.in.flags & VBOXVHWA_CKEY_SRCOVERLAY)
     {
-        pSurf->setDefaultSrcOverlayCKey(&VBoxVHWAColorKey(pCmd->u.in.CKey.high, pCmd->u.in.CKey.low));
+        VBoxVHWAColorKey ckey(pCmd->u.in.CKey.high, pCmd->u.in.CKey.low);
+        pSurf->setDefaultSrcOverlayCKey(&ckey);
     }
 
@@ -4037,4 +4054,5 @@
 static DECLCALLBACK(int) vboxQGLLoadExec(PSSMHANDLE pSSM, void *pvUser, uint32_t u32Version, uint32_t uPhase)
 {
+    Q_UNUSED(uPhase);
     VBoxGLWidget * pw = (VBoxGLWidget*)pvUser;
     return pw->vhwaLoadExec(pSSM, u32Version);
@@ -4122,7 +4140,9 @@
 int VBoxGLWidget::vhwaLoadSurface(struct SSMHANDLE * pSSM, uint32_t u32Version)
 {
+    Q_UNUSED(u32Version);
+
     VBOXQGL_LOAD_SURFSTART(pSSM);
 
-    char *buf = new char[VBOXVHWACMD_SIZE(VBOXVHWACMD_SURF_CREATE)];
+    char *buf = (char*)malloc(VBOXVHWACMD_SIZE(VBOXVHWACMD_SURF_CREATE));
     memset(buf, 0, sizeof(buf));
     VBOXVHWACMD * pCmd = (VBOXVHWACMD*)buf;
@@ -4271,4 +4291,6 @@
 int VBoxGLWidget::vhwaLoadOverlayData(struct SSMHANDLE * pSSM, uint32_t u32Version)
 {
+    Q_UNUSED(u32Version);
+    
     VBOXQGL_LOAD_OVERLAYSTART(pSSM);
 
@@ -4588,4 +4610,6 @@
 void VBoxGLWidget::vboxDoPaint(void *pe)
 {
+    Q_UNUSED(pe);
+
 #ifdef VBOXQGL_DBG_SURF
     vboxDoTestSurfaces(NULL);
@@ -4718,5 +4742,5 @@
         if (!fallback)
         {
-            ulong virtWdt = bitsPerLine / re->bitsPerPixel();
+            // ulong virtWdt = bitsPerLine / re->bitsPerPixel();
             mPixelFormat = FramebufferPixelFormat_FOURCC_RGB;
             mUsesGuestVRAM = true;
