summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2010-03-11 15:44:08 +0100
committerTom Cooksey <thomas.cooksey@nokia.com>2010-03-11 15:51:57 +0100
commitfc0e0198c5e7ef75d1650bca39a5f06ebddfb932 (patch)
treec0b1fb6e5f8349fb4bde83fc568775aaff2990d6
parent82fa80a6b28ea5a4d3e245f531fea22a689c7ad3 (diff)
downloadqt4-tools-fc0e0198c5e7ef75d1650bca39a5f06ebddfb932.tar.gz
Delete the QGLContext in ~QX11GLPixmapData
This also includes changes which allow QGLContext to not own it's own QEglContext. With X11GL, the QEglContext gets reused by multiple QGLContexts so it is important QGLContext doesn't delete it. Reviewed-By: TrustMe
-rw-r--r--src/gui/egl/qegl.cpp2
-rw-r--r--src/opengl/qgl.cpp1
-rw-r--r--src/opengl/qgl_egl.cpp5
-rw-r--r--src/opengl/qgl_p.h1
-rw-r--r--src/opengl/qgl_qws.cpp1
-rw-r--r--src/opengl/qgl_wince.cpp1
-rw-r--r--src/opengl/qgl_x11egl.cpp1
-rw-r--r--src/opengl/qpixmapdata_x11gl_egl.cpp3
8 files changed, 12 insertions, 3 deletions
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp
index 6e0331f507..b8705239b8 100644
--- a/src/gui/egl/qegl.cpp
+++ b/src/gui/egl/qegl.cpp
@@ -60,7 +60,7 @@ static QEglContext * volatile currentVGContext = 0;
QEglContext::QEglContext()
: apiType(QEgl::OpenGL)
, ctx(EGL_NO_CONTEXT)
- , cfg(0)
+ , cfg(QEGL_NO_CONFIG)
, currentSurface(EGL_NO_SURFACE)
, current(false)
, ownsContext(true)
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index c6ecef6689..58ac642a39 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1583,6 +1583,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
vi = 0;
#endif
#if defined(QT_OPENGL_ES)
+ ownsEglContext = false;
eglContext = 0;
eglSurface = EGL_NO_SURFACE;
#endif
diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp
index c08d6fd109..aa8d2bc8ee 100644
--- a/src/opengl/qgl_egl.cpp
+++ b/src/opengl/qgl_egl.cpp
@@ -164,10 +164,11 @@ void QGLContext::reset()
return;
d->cleanup();
doneCurrent();
- if (d->eglContext) {
+ if (d->eglContext && d->ownsEglContext) {
d->destroyEglSurfaceForDevice();
delete d->eglContext;
}
+ d->ownsEglContext = false;
d->eglContext = 0;
d->eglSurface = EGL_NO_SURFACE;
d->crWin = false;
@@ -215,7 +216,7 @@ void QGLContextPrivate::destroyEglSurfaceForDevice()
#ifdef Q_WS_X11
// Make sure we don't call eglDestroySurface on a surface which
// was created for a different winId:
- if (paintDevice->devType() == QInternal::Widget) {
+ if (paintDevice && paintDevice->devType() == QInternal::Widget) {
QGLWidget* w = static_cast<QGLWidget*>(paintDevice);
if (w->d_func()->eglSurfaceWindowId == w->winId())
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 5e524a733c..f66031ab22 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -347,6 +347,7 @@ public:
HDC hbitmap_hdc;
#endif
#if defined(QT_OPENGL_ES)
+ bool ownsEglContext;
QEglContext *eglContext;
EGLSurface eglSurface;
void destroyEglSurfaceForDevice();
diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp
index 96b2454b0e..38c3774464 100644
--- a/src/opengl/qgl_qws.cpp
+++ b/src/opengl/qgl_qws.cpp
@@ -182,6 +182,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
// Get the display and initialize it.
d->eglContext = new QEglContext();
+ d->ownsEglContext = true;
d->eglContext->setApi(QEgl::OpenGL);
// Construct the configuration we need for this surface.
diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp
index fefcca2ddf..47a19b5719 100644
--- a/src/opengl/qgl_wince.cpp
+++ b/src/opengl/qgl_wince.cpp
@@ -145,6 +145,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
// Get the display and initialize it.
d->eglContext = new QEglContext();
+ d->ownsEglContext = true;
d->eglContext->setApi(QEgl::OpenGL);
// Construct the configuration we need for this surface.
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index fe87c6536f..0954e69471 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -182,6 +182,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
// Only create the eglContext if we don't already have one:
if (d->eglContext == 0) {
d->eglContext = new QEglContext();
+ d->ownsEglContext = true;
d->eglContext->setApi(QEgl::OpenGL);
// If the device is a widget with WA_TranslucentBackground set, make sure the glFormat
diff --git a/src/opengl/qpixmapdata_x11gl_egl.cpp b/src/opengl/qpixmapdata_x11gl_egl.cpp
index d7fae1626f..a01eec4c03 100644
--- a/src/opengl/qpixmapdata_x11gl_egl.cpp
+++ b/src/opengl/qpixmapdata_x11gl_egl.cpp
@@ -181,6 +181,8 @@ QX11GLPixmapData::QX11GLPixmapData()
QX11GLPixmapData::~QX11GLPixmapData()
{
+ if (ctx)
+ delete ctx;
}
#if !defined(QT_OPENGL_ES_1)
@@ -245,6 +247,7 @@ void QX11GLPixmapData::beginPaint()
if ((EGLSurface)gl_surface == EGL_NO_SURFACE) {
QPixmap tmpPixmap(this);
EGLConfig cfg = ctx->d_func()->eglContext->config();
+ Q_ASSERT(cfg != QEGL_NO_CONFIG);
EGLSurface surface = QEgl::createSurface(&tmpPixmap, cfg);
if (surface == EGL_NO_SURFACE) {