src/opengl/qgl_egl.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   140     if (!d->valid)
   140     if (!d->valid)
   141         return;
   141         return;
   142     d->cleanup();
   142     d->cleanup();
   143     doneCurrent();
   143     doneCurrent();
   144     if (d->eglContext) {
   144     if (d->eglContext) {
   145         if (d->eglSurface != EGL_NO_SURFACE) {
   145         d->destroyEglSurfaceForDevice();
   146 #ifdef Q_WS_X11
       
   147             // Make sure we don't call eglDestroySurface on a surface which
       
   148             // was created for a different winId:
       
   149             if (d->paintDevice->devType() == QInternal::Widget) {
       
   150                 QGLWidget* w = static_cast<QGLWidget*>(d->paintDevice);
       
   151 
       
   152                 if (w->d_func()->eglSurfaceWindowId == w->winId())
       
   153                     eglDestroySurface(d->eglContext->display(), d->eglSurface);
       
   154             } else
       
   155 #endif
       
   156                 eglDestroySurface(d->eglContext->display(), d->eglSurface);
       
   157         }
       
   158         delete d->eglContext;
   146         delete d->eglContext;
   159     }
   147     }
   160     d->eglContext = 0;
   148     d->eglContext = 0;
   161     d->eglSurface = EGL_NO_SURFACE;
   149     d->eglSurface = EGL_NO_SURFACE;
   162     d->crWin = false;
   150     d->crWin = false;
   196         return;
   184         return;
   197 
   185 
   198     d->eglContext->swapBuffers(d->eglSurface);
   186     d->eglContext->swapBuffers(d->eglSurface);
   199 }
   187 }
   200 
   188 
       
   189 void QGLContextPrivate::destroyEglSurfaceForDevice()
       
   190 {
       
   191     if (eglSurface != EGL_NO_SURFACE) {
       
   192 #ifdef Q_WS_X11
       
   193         // Make sure we don't call eglDestroySurface on a surface which
       
   194         // was created for a different winId:
       
   195         if (paintDevice->devType() == QInternal::Widget) {
       
   196             QGLWidget* w = static_cast<QGLWidget*>(paintDevice);
       
   197 
       
   198             if (w->d_func()->eglSurfaceWindowId == w->winId())
       
   199                 eglDestroySurface(eglContext->display(), eglSurface);
       
   200             else
       
   201                 qWarning("WARNING: Potential EGL surface leak!");
       
   202         } else
       
   203 #endif
       
   204             eglDestroySurface(eglContext->display(), eglSurface);
       
   205         eglSurface = EGL_NO_SURFACE;
       
   206     }
       
   207 }
       
   208 
   201 void QGLWidget::setMouseTracking(bool enable)
   209 void QGLWidget::setMouseTracking(bool enable)
   202 {
   210 {
   203     QWidget::setMouseTracking(enable);
   211     QWidget::setMouseTracking(enable);
   204 }
   212 }
   205 
   213