From 78ff3973c8745d8e12a0e71bd37dea47be954741 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 19 Apr 2016 14:44:34 +0200 Subject: Fix crash when instantiating a QCoreApplication When linking against QtWebEngineWidgets, a Q_COREAPP_STARTUP_FUNCTION is installed, which is then called from QCoreApplication::init. In that function, check whether qApp is a QGuiApplication or derivative before calling QtWebEngineCore::initialize. Change-Id: I16a3cdda2c707040ad3707a83a192fcb9059ddc4 Task-number: QTBUG-51789 Task-number: QTBUG-52539 Reviewed-by: Andy Shaw --- src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp index 1ef6386ad..263376e45 100644 --- a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp +++ b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp @@ -36,7 +36,7 @@ #include "qtwebenginewidgetsglobal.h" -#include +#include namespace QtWebEngineCore { @@ -46,6 +46,10 @@ namespace QtWebEngineCore QT_BEGIN_NAMESPACE static void initialize() { + // Bail out silently if the user did not construct a QGuiApplication. + if (!qobject_cast(QCoreApplication::instance())) + return; + QtWebEngineCore::initialize(); } -- cgit v1.2.3