make sure clear the draw and read EGLSurface when eglMakeCurrent() is called for unbinding from the thread
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index f50257a..0df2bba 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -384,7 +384,7 @@
 
 void egl_window_surface_v2_t::disconnect() 
 {
-    if (buffer) {
+    if (buffer && bits) {
         bits = NULL;
         unlock(buffer);
     }
@@ -1681,10 +1681,12 @@
                 egl_surface_t* d = (egl_surface_t*)c->draw;
                 egl_surface_t* r = (egl_surface_t*)c->read;
                 if (d) {
+                    c->draw = 0;
                     d->ctx = EGL_NO_CONTEXT;
                     d->disconnect();
                 }
                 if (r) {
+                    c->read = 0;
                     r->ctx = EGL_NO_CONTEXT;
                     // FIXME: unlock/disconnect the read surface too 
                 }