diff options
author | Jesus Fernandez <jesus.fernandez@qt.io> | 2018-09-10 18:44:30 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-09-11 08:08:43 +0000 |
commit | 64f6bf45187a449986b5a5153abcc75ce987e9e0 (patch) | |
tree | 0d01a47323e3ec82503b8b6f51f5852f5d156a31 | |
parent | 3237f7bffa81285994f4da03120efafe1dd44eb8 (diff) |
Fix OpenGL context crash
Task-number: QTBUG-70458
Change-Id: I00efefeb9f8c0bf245c77e68c285e596c60755e1
Reviewed-by: Liang Qi <liang.qi@qt.io>
-rw-r--r-- | src/plugins/platforms/webgl/qwebglcontext.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/plugins/platforms/webgl/qwebglcontext.cpp b/src/plugins/platforms/webgl/qwebglcontext.cpp index cb56182..409b093 100644 --- a/src/plugins/platforms/webgl/qwebglcontext.cpp +++ b/src/plugins/platforms/webgl/qwebglcontext.cpp @@ -41,6 +41,7 @@ #include <QtCore/qrect.h> #include <QtCore/qset.h> #include <QtGui/private/qguiapplication_p.h> +#include <QtGui/private/qopenglcontext_p.h> #include <QtGui/qguiapplication.h> #include <QtGui/qimage.h> #include <QtGui/qopenglcontext.h> @@ -1506,17 +1507,16 @@ bool QWebGLContext::makeCurrent(QPlatformSurface *surface) return false; } - auto context = QOpenGLContext::currentContext(); - Q_ASSERT(context); - auto handle = static_cast<QWebGLContext *>(context->handle()); - handle->d_func()->currentSurface = surface; + QOpenGLContextPrivate::setCurrentContext(context()); + d->currentSurface = surface; + auto event = createEvent(QStringLiteral("makeCurrent")); if (!event) return false; event->addInt(d->id); if (surface->surface()->surfaceClass() == QSurface::Window) { auto window = static_cast<QWebGLWindow *>(surface); - if (s_contextData[handle->id()].cachedParameters.isEmpty()) { + if (s_contextData[id()].cachedParameters.isEmpty()) { auto future = window->d_func()->defaults.get_future(); std::future_status status = std::future_status::timeout; while (status == std::future_status::timeout) { @@ -1524,7 +1524,7 @@ bool QWebGLContext::makeCurrent(QPlatformSurface *surface) return false; status = future.wait_for(std::chrono::milliseconds(100)); } - s_contextData[handle->id()].cachedParameters = future.get(); + s_contextData[id()].cachedParameters = future.get(); } event->addInt(window->window()->width()); event->addInt(window->window()->height()); |