Index: /trunk/src/VBox/Frontends/VirtualBox/include/VBoxFBOverlay.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/include/VBoxFBOverlay.h	(revision 22920)
+++ /trunk/src/VBox/Frontends/VirtualBox/include/VBoxFBOverlay.h	(revision 22921)
@@ -580,5 +580,5 @@
     void deleteDisplay();
 
-    GLuint createDisplay(VBoxVHWASurfaceBase *pPrimary);
+    int createDisplay(VBoxVHWASurfaceBase *pPrimary, GLuint *pDisplay);
     void doDisplay(VBoxVHWASurfaceBase *pPrimary, VBoxVHWAGlProgramVHWA * pProgram, bool bBindDst);
     bool synchTexMem(const QRect * aRect);
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp	(revision 22920)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp	(revision 22921)
@@ -2737,10 +2737,11 @@
         )
 {
-    {
-        if(mVisibleDisplayInitialized)
+    if(mVisibleDisplayInitialized)
+    {
+        if(mVisibleDisplay)
         {
             glDeleteLists(mVisibleDisplay, 1);
-            mVisibleDisplayInitialized = false;
-        }
+        }
+        mVisibleDisplayInitialized = false;
     }
 }
@@ -2826,5 +2827,5 @@
 }
 
-GLuint VBoxVHWASurfaceBase::createDisplay(VBoxVHWASurfaceBase *pPrimary)
+int VBoxVHWASurfaceBase::createDisplay(VBoxVHWASurfaceBase *pPrimary, GLuint *pDisplay)
 {
     if(mVisibleTargRect.isEmpty())
@@ -2837,5 +2838,6 @@
     if(mVisibleSrcRect.isEmpty())
     {
-        return 0;
+        *pDisplay = 0;
+        return VINF_SUCCESS;
     }
 
@@ -2857,14 +2859,47 @@
     }
 
+    glGetError(); /* clear the err flag */
     GLuint display = glGenLists(1);
-    VBOXQGL_ASSERTNOERR();
-    glNewList(display, GL_COMPILE);
-
-    doDisplay(pPrimary, pProgram, pDstCKey != NULL);
-
-    glEndList();
-    VBOXQGL_ASSERTNOERR();
-
-    return display;
+    GLenum err = glGetError();
+    if(err == GL_NO_ERROR)
+    {
+        Assert(display);
+        if(!display)
+        {
+            /* well, it seems it should not return 0 on success according to the spec,
+             * but just in case, pick another one */
+            display = glGenLists(1);
+            err = glGetError();
+            if(err == GL_NO_ERROR)
+            {
+                Assert(display);
+            }
+            else
+            {
+                /* we are failed */
+                Assert(!display);
+                display = 0;
+            }
+        }
+
+        if(display)
+        {
+            glNewList(display, GL_COMPILE);
+
+            doDisplay(pPrimary, pProgram, pDstCKey != NULL);
+
+            glEndList();
+            VBOXQGL_ASSERTNOERR();
+            *pDisplay = display;
+            return VINF_SUCCESS;
+        }
+    }
+    else
+    {
+        VBOXQGLLOG(("gl error ocured (0x%x)\n", err));
+        Assert(err == GL_NO_ERROR);
+    }
+
+    return VERR_GENERAL_FAILURE;
 }
 
@@ -2873,6 +2908,9 @@
     deleteDisplay();
 
-    mVisibleDisplay = createDisplay(pPrimary);
-    mVisibleDisplayInitialized = true;
+    int rc = createDisplay(pPrimary, &mVisibleDisplay);
+    if(RT_SUCCESS(rc))
+    {
+        mVisibleDisplayInitialized = true;
+    }
 }
 
@@ -2918,6 +2956,7 @@
         return false;
 
-#ifdef DEBUG_misha
-    if(0)
+    Assert(mVisibleDisplay);
+
+    if(!mVisibleDisplayInitialized)
     {
         VBoxVHWAGlProgramVHWA * pProgram = NULL;
@@ -2943,5 +2982,4 @@
     }
     else
-#endif
     {
         VBOXQGL_CHECKERR(
