diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-08-04 11:48:43 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-08-04 12:04:32 (GMT) |
commit | 7992c2d3a4413082fd40e4099f735d95d522b0f3 (patch) | |
tree | 75b37c50356b40508d64e1eb6bf85a9fc0a0d4e4 /src/opengl/qgl_qpa.cpp | |
parent | 34a3b5d2a0c86a534b9d7b036fb1aaf1eb1c65b1 (diff) | |
download | Qt-7992c2d3a4413082fd40e4099f735d95d522b0f3.zip Qt-7992c2d3a4413082fd40e4099f735d95d522b0f3.tar.gz Qt-7992c2d3a4413082fd40e4099f735d95d522b0f3.tar.bz2 |
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 f859ff1..5e05de1 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); } |