diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-11-27 17:38:42 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2015-11-27 19:24:34 +0000 |
commit | 37a55e8840e53c78f855f17f2b5f453ed2058099 (patch) | |
tree | 9d5dcbe6f8b5078fe6a165e3b35b76817374fbd5 /src/widgets/kernel/qwidget.cpp | |
parent | eddb938c39d03e163ef47c965ea07ab19250eeed (diff) | |
parent | 8c57e8c012d1045f2bdb30d376625a32c33fdfc4 (diff) |
Merge "Merge remote-tracking branch 'origin/5.5' into 5.6" into refs/staging/5.6
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 94099aac7a..b8b8640cea 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -73,6 +73,7 @@ #include <QtGui/qinputmethod.h> #include <QtGui/qopenglcontext.h> #include <QtGui/private/qopenglcontext_p.h> +#include <QtGui/qoffscreensurface.h> #include <private/qgraphicseffect_p.h> #include <qbackingstore.h> @@ -1822,26 +1823,49 @@ void QWidgetPrivate::deleteSysExtra() { } +static void deleteBackingStore(QWidgetPrivate *d) +{ + QTLWExtra *topData = d->topData(); + + // The context must be current when destroying the backing store as it may attempt to + // release resources like textures and shader programs. The window may not be suitable + // anymore as there will often not be a platform window underneath at this stage. Fall + // back to a QOffscreenSurface in this case. + QScopedPointer<QOffscreenSurface> tempSurface; +#ifndef QT_NO_OPENGL + if (d->textureChildSeen && topData->shareContext) { + if (topData->window->handle()) { + topData->shareContext->makeCurrent(topData->window); + } else { + tempSurface.reset(new QOffscreenSurface); + tempSurface->setFormat(topData->shareContext->format()); + tempSurface->create(); + topData->shareContext->makeCurrent(tempSurface.data()); + } + } +#endif + + delete topData->backingStore; + topData->backingStore = 0; + +#ifndef QT_NO_OPENGL + if (d->textureChildSeen && topData->shareContext) + topData->shareContext->doneCurrent(); +#endif +} + void QWidgetPrivate::deleteTLSysExtra() { if (extra && extra->topextra) { //the qplatformbackingstore may hold a reference to the window, so the backingstore //needs to be deleted first. If the backingstore holds GL resources, we need to - // make the context current here, since the platform bs does not have a reference - // to the widget. + // make the context current here. This is taken care of by deleteBackingStore(). -#ifndef QT_NO_OPENGL - if (textureChildSeen && extra->topextra->shareContext) - extra->topextra->shareContext->makeCurrent(extra->topextra->window); -#endif extra->topextra->backingStoreTracker.destroy(); - delete extra->topextra->backingStore; - extra->topextra->backingStore = 0; + deleteBackingStore(this); #ifndef QT_NO_OPENGL qDeleteAll(extra->topextra->widgetTextures); extra->topextra->widgetTextures.clear(); - if (textureChildSeen && extra->topextra->shareContext) - extra->topextra->shareContext->doneCurrent(); delete extra->topextra->shareContext; extra->topextra->shareContext = 0; #endif @@ -12013,7 +12037,7 @@ void QWidget::setBackingStore(QBackingStore *store) return; QBackingStore *oldStore = topData->backingStore; - delete topData->backingStore; + deleteBackingStore(d); topData->backingStore = store; QWidgetBackingStore *bs = d->maybeBackingStore(); |