Index: /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c	(revision 43747)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c	(revision 43748)
@@ -173,5 +173,5 @@
 renderspuDestroyContext( GLint ctx )
 {
-    ContextInfo *context;
+    ContextInfo *context, *curCtx;
 
     CRASSERT(ctx);
@@ -185,4 +185,8 @@
     }
     crHashtableDelete(render_spu.contextTable, ctx, crFree);
+
+    curCtx = GET_CONTEXT_VAL();
+    if (curCtx == context)
+        SET_CONTEXT_VAL(NULL);
 }
 
Index: /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h	(revision 43747)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h	(revision 43748)
@@ -280,8 +280,17 @@
 #ifdef CHROMIUM_THREADSAFE
 extern CRtsd _RenderTSD;
-#define GET_CONTEXT(T)  ContextInfo *T = (ContextInfo *) crGetTSD(&_RenderTSD)
+#define GET_CONTEXT_VAL() ((ContextInfo *) crGetTSD(&_RenderTSD))
+#define SET_CONTEXT_VAL(_v) do { \
+        crSetTSD(&_RenderTSD, (_v)); \
+    } while (0)
 #else
-#define GET_CONTEXT(T)  ContextInfo *T = render_spu.currentContext
-#endif
+#define GET_CONTEXT_VAL() (render_spu.currentContext)
+#define SET_CONTEXT_VAL(_v) do { \
+        render_spu.currentContext = (_v); \
+    } while (0)
+
+#endif
+
+#define GET_CONTEXT(T)  ContextInfo *T = GET_CONTEXT_VAL()
 
 extern void renderspuSetVBoxConfiguration( RenderSPU *spu );
