diff options
-rw-r--r-- | src/core/api/qtwebenginecoreglobal.cpp | 5 | ||||
-rw-r--r-- | src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp | 17 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp index 0e857d7d9..e60e6139e 100644 --- a/src/core/api/qtwebenginecoreglobal.cpp +++ b/src/core/api/qtwebenginecoreglobal.cpp @@ -75,6 +75,11 @@ QWEBENGINE_PRIVATE_EXPORT void initialize() qFatal("QtWebEngine::initialize() must be called after the construction of the application object."); return; } + + // Bail out silently if the user did not construct a QGuiApplication. + if (!qobject_cast<QGuiApplication *>(app)) + return; + if (app->thread() != QThread::currentThread()) { qFatal("QtWebEngine::initialize() must be called from the Qt gui thread."); return; diff --git a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp index 263376e45..5ebb8b546 100644 --- a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp +++ b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp @@ -36,7 +36,7 @@ #include "qtwebenginewidgetsglobal.h" -#include <QGuiApplication> +#include <QCoreApplication> namespace QtWebEngineCore { @@ -46,13 +46,18 @@ namespace QtWebEngineCore QT_BEGIN_NAMESPACE static void initialize() { - // Bail out silently if the user did not construct a QGuiApplication. - if (!qobject_cast<QGuiApplication *>(QCoreApplication::instance())) + //On window/ANGLE, calling QtWebEngine::initialize from DllMain will result in a crash. + //To ensure it doesn't, we check that when loading the library + //QCoreApplication is not yet instantiated, ensuring the call will be deferred +#if defined(Q_OS_WIN) + if (QCoreApplication::instance() + && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) { return; - - QtWebEngineCore::initialize(); + } +#endif + qAddPreRoutine(QtWebEngineCore::initialize); } -Q_COREAPP_STARTUP_FUNCTION(initialize) +Q_CONSTRUCTOR_FUNCTION(initialize) QT_END_NAMESPACE |