diff options
author | Corentin Jabot <corentinjabot@gmail.com> | 2015-12-16 10:18:30 +0100 |
---|---|---|
committer | Corentin Jabot <corentinjabot@gmail.com> | 2015-12-18 14:10:13 +0000 |
commit | 6a8d99ab00ace2084820547572dc05ac8ad2bc5a (patch) | |
tree | 11b8d09ed4ac18e82f74e9abd5470b773ae39b70 /src/webenginewidgets | |
parent | 1cf9175e06db9c8c0388e21279b15b011fb593c2 (diff) |
Never call QtWebEngine::initialize from DllMain
On windows, calling QtWebEngine::initialize from DllMain may crash,
depending on what QPA backend is used.
We make sure to only add a qAddPreRoutine initializing QtWebEngine
if there is no instance of QCoreApplication.
By doing so, we support linking to QtWebEngineWidget from a plugin,
while still initializing the WebEngine automatically when linked to
the main application binary.
Change-Id: I4f72aa10103de29ce53fe3dd88457d093b705599
Task-number: QTBUG-46720
Reviewed-by: Jocelyn Turcotte (Woboq GmbH) <jturcotte@woboq.com>
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r-- | src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp index 4feacf748..b17516ad6 100644 --- a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp +++ b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp @@ -38,13 +38,23 @@ #include "qtwebengineglobal.h" #include <QCoreApplication> +#include <QOpenGLContext> QT_BEGIN_NAMESPACE static void initialize() { - QtWebEngine::initialize(); + //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; + } +#endif + qAddPreRoutine(QtWebEngine::initialize); } -Q_COREAPP_STARTUP_FUNCTION(initialize) +Q_CONSTRUCTOR_FUNCTION(initialize) QT_END_NAMESPACE |