From bc00d396585e75dcaaed5e954519723b5046e070 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 22 Feb 2016 16:08:29 +0100 Subject: OSX: Fix QSurfaceFormat check to allow < 3.2 OpenGL profiles. Currently if a < 3.2 OpenGL Compatibility profile is requested on OSX, a webengine application would crash saying that the global profile does not match the default profile. That happens because in the Cocoa QPA any requested OpenGL Compatibility profile or Core profile with version smaller than 3.2 gets reset to QSurfaceFormat::NoProfile and version 2.1. Fix consists in making sure that the QSurfaceFormat check only considers Core profile with versions >= 3.2. All other combinations would result in NoProfile 2.1 and thus not cause any issues for webengine. Change-Id: I7c9866d761c052e52389022abe8e213d062db41f Task-number: QTBUG-51058 Reviewed-by: Kai Koehne Reviewed-by: Laszlo Agocs --- .../render_widget_host_view_qt_delegate_widget.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp') diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp index 92d0c6de9..937b26c0b 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp @@ -74,11 +74,16 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende QSurfaceFormat sharedFormat = globalSharedContext->format(); #ifdef Q_OS_OSX - // Check that the default QSurfaceFormat OpenGL profile matches the global OpenGL shared - // context profile, otherwise this could lead to a nasty crash. + // Check that the default QSurfaceFormat OpenGL profile is compatible with the global OpenGL + // shared context profile, otherwise this could lead to a nasty crash. QSurfaceFormat defaultFormat = QSurfaceFormat::defaultFormat(); - if (defaultFormat.profile() != sharedFormat.profile()) { - qFatal("QWebEngine: Default QSurfaceFormat OpenGL profile does not match global shared context OpenGL profile. Please make sure you set a new QSurfaceFormat before the QtGui application instance is created."); + + if (defaultFormat.profile() != sharedFormat.profile() + && defaultFormat.profile() == QSurfaceFormat::CoreProfile + && defaultFormat.version() >= qMakePair(3, 2)) { + qFatal("QWebEngine: Default QSurfaceFormat OpenGL profile is not compatible with the " + "global shared context OpenGL profile. Please make sure you set a compatible " + "QSurfaceFormat before the QtGui application instance is created."); } #endif -- cgit v1.2.3