diff options
author | Jani Hautakangas <jani.hautakangas@nokia.com> | 2011-10-18 10:04:21 (GMT) |
---|---|---|
committer | Jani Hautakangas <jani.hautakangas@nokia.com> | 2011-10-18 10:19:05 (GMT) |
commit | b9a3d4bf7827aa631995d47233d47583917a5a7f (patch) | |
tree | fe28db0923749bc69ec53da6b016209f1bce6f79 | |
parent | 17e0607ef47e455f56894e134541c46b42e7cdd9 (diff) | |
download | Qt-b9a3d4bf7827aa631995d47233d47583917a5a7f.zip Qt-b9a3d4bf7827aa631995d47233d47583917a5a7f.tar.gz Qt-b9a3d4bf7827aa631995d47233d47583917a5a7f.tar.bz2 |
Fix to QGLWidget crash
QGLWidget crashed due to regression
caused by fix to QTTH-1553. Crash only
occurred if application was locked to
landscape mode but started when device
was in portrait mode.
Task-number: QTTH-1597
Reviewed-by: Laszlo Agocs
-rw-r--r-- | src/opengl/qgl.cpp | 7 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 2 | ||||
-rw-r--r-- | src/opengl/qgl_symbian.cpp | 18 |
3 files changed, 18 insertions, 9 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index ca16cca..3b3da43 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4297,7 +4297,7 @@ bool QGLWidget::event(QEvent *e) // if we've reparented a window that has the current context // bound, we need to rebind that context to the new window id if (d->glcx == QGLContext::currentContext()) - makeCurrent(); + makeCurrent(); // Shouldn't happen but keep it here just for sure if (testAttribute(Qt::WA_TranslucentBackground)) setContext(new QGLContext(d->glcx->requestedFormat(), this)); @@ -4305,8 +4305,11 @@ bool QGLWidget::event(QEvent *e) // A re-parent is likely to destroy the Symbian window and re-create it. It is important // that we free the EGL surface _before_ the winID changes - otherwise we can leak. - if (e->type() == QEvent::ParentAboutToChange) + if (e->type() == QEvent::ParentAboutToChange) { + if (d->glcx == QGLContext::currentContext()) + d->glcx->doneCurrent(); d->glcx->d_func()->destroyEglSurfaceForDevice(); + } if ((e->type() == QEvent::ParentChange) || (e->type() == QEvent::WindowStateChange)) { // The window may have been re-created during re-parent or state change - if so, the EGL diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 2ca8dc9..c56b2db 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -175,6 +175,7 @@ public: #endif #if defined(Q_OS_SYMBIAN) , eglSurfaceWindowId(0) + , surfaceSizeInitialized(false) #endif { isGLWidget = 1; @@ -220,6 +221,7 @@ public: #ifdef Q_OS_SYMBIAN void recreateEglSurface(); WId eglSurfaceWindowId; + bool surfaceSizeInitialized : 1; #endif }; diff --git a/src/opengl/qgl_symbian.cpp b/src/opengl/qgl_symbian.cpp index b8e5c22..94c63fc 100644 --- a/src/opengl/qgl_symbian.cpp +++ b/src/opengl/qgl_symbian.cpp @@ -259,7 +259,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) // almost same as return true; } -void QGLWidget::resizeEvent(QResizeEvent *) +void QGLWidget::resizeEvent(QResizeEvent *e) { Q_D(QGLWidget); if (!isValid()) @@ -270,17 +270,18 @@ void QGLWidget::resizeEvent(QResizeEvent *) if (this == qt_gl_share_widget()) return; - if (QGLContext::currentContext()) - doneCurrent(); - - // Symbian needs to recreate the surface on resize. - d->recreateEglSurface(); + if (!d->surfaceSizeInitialized || e->oldSize() != e->size()) { + // On Symbian we need to recreate the surface on resize. + d->recreateEglSurface(); + d->surfaceSizeInitialized = true; + } makeCurrent(); + if (!d->glcx->initialized()) glInit(); + resizeGL(width(), height()); - //handle overlay } const QGLContext* QGLWidget::overlayContext() const @@ -363,6 +364,9 @@ void QGLWidgetPrivate::recreateEglSurface() WId currentId = q->winId(); if (glcx->d_func()->eglSurface != EGL_NO_SURFACE) { + if (glcx == QGLContext::currentContext()) + glcx->doneCurrent(); + eglDestroySurface(glcx->d_func()->eglContext->display(), glcx->d_func()->eglSurface); } |