diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-08-04 13:48:43 +0200 |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-08-04 14:04:32 +0200 |
commit | 7992c2d3a4413082fd40e4099f735d95d522b0f3 (patch) | |
tree | 75b37c50356b40508d64e1eb6bf85a9fc0a0d4e4 /src/opengl/qgl_qpa.cpp | |
parent | 34a3b5d2a0c86a534b9d7b036fb1aaf1eb1c65b1 (diff) |
Make QWidget::setPlatformWindowFormat recreate platformWindow
if the platformWindow is visible. Also had to make sure that the
QGLContext of a QGLWidget was recreated.
Diffstat (limited to 'src/opengl/qgl_qpa.cpp')
-rw-r--r-- | src/opengl/qgl_qpa.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index f859ff1c3b..5e05de104d 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -129,11 +129,15 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) if (!widget->platformWindow()){ QGLFormat glformat = format(); QPlatformWindowFormat winFormat = qt_glformat_to_platformwindowformat(glformat); + if (shareContext) { + winFormat.setSharedContext(shareContext->d_func()->platformContext); + } winFormat.setWindowApi(QPlatformWindowFormat::OpenGL); widget->setPlatformWindowFormat(winFormat); widget->winId();//make window } d->platformContext = widget->platformWindow()->glContext(); + Q_ASSERT(d->platformContext); d->glFormat = qt_platformwindowformat_to_glformat(d->platformContext->platformWindowFormat()); d->valid =(bool) d->platformContext; } @@ -147,14 +151,6 @@ void QGLContext::reset() if (!d->valid) return; d->cleanup(); - doneCurrent(); - - if (d->platformContext) { - if (d->paintDevice && d->paintDevice->devType() == QInternal::Widget) { - QWidget *widget = static_cast<QWidget *>(d->paintDevice); - widget->destroy(); - } - } d->crWin = false; d->sharing = false; @@ -204,8 +200,6 @@ void QGLWidget::setContext(QGLContext *context, return; } - if (d->glcx) - d->glcx->doneCurrent(); QGLContext* oldcx = d->glcx; d->glcx = context; @@ -286,11 +280,26 @@ void QGLWidget::setMouseTracking(bool enable) bool QGLWidget::event(QEvent *e) { + Q_D(QGLWidget); + if (e->type() == QEvent::WinIdChange) { + if (d->glcx->isValid()) { + if (QGLContext::currentContext() == d->glcx) + QGLContextPrivate::setCurrentContext(0); //Its not valid anymore + setContext(new QGLContext(d->glcx->requestedFormat(), this)); + + } + } return QWidget::event(e); } void QGLWidget::resizeEvent(QResizeEvent *e) { + Q_D(QGLWidget); + if (!isValid()) + return; + if (!d->glcx->initialized()) + glInit(); + resizeGL(width(), height()); return QWidget::resizeEvent(e); } |