From e86aa68ac75da4e20b55c2bca91d3f98a1e53090 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 3 Jul 2025 09:42:53 +0200 Subject: Fix crash if ui delegates are not deployed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In case delegate for touch handle can not be loaded bail out and simply return nullptr as TouchHandleDrawableQt works fine without delegate (guards against nullptr). Note all other dialog already bailout in case default delegate can not be loaded. Tested on bookworm with 6.8.3 Fixes: QTBUG-111907 Pick-to: 6.10 6.9 6.8 Change-Id: Ib509b63010888fa718f23148c06d973382cad428 Reviewed-by: Michael BrĂ¼ning --- src/webenginequick/api/qquickwebengineview.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/webenginequick/api') diff --git a/src/webenginequick/api/qquickwebengineview.cpp b/src/webenginequick/api/qquickwebengineview.cpp index dae4a3753..ade8b451c 100644 --- a/src/webenginequick/api/qquickwebengineview.cpp +++ b/src/webenginequick/api/qquickwebengineview.cpp @@ -1450,8 +1450,9 @@ QQuickWebEngineViewPrivate::createTouchHandleDelegate(const QMap &i { Q_Q(QQuickWebEngineView); // lifecycle managed by Chromium's TouchHandleDrawable - QQuickWebEngineTouchHandle *handle = new QQuickWebEngineTouchHandle(); + QQuickWebEngineTouchHandle *handle(nullptr); if (m_touchHandleDelegate) { + handle = new QQuickWebEngineTouchHandle(); QQmlContext *qmlContext = QQmlEngine::contextForObject(q); QQmlContext *context = new QQmlContext(qmlContext, handle); context->setContextObject(handle); @@ -1462,7 +1463,9 @@ QQuickWebEngineViewPrivate::createTouchHandleDelegate(const QMap &i handle->setItem(item, false); } else { QQuickItem *item = ui()->createTouchHandle(); - Q_ASSERT(item); + if (!item) { + return nullptr; + } QQmlEngine *engine = qmlEngine(item); Q_ASSERT(engine); QQuickWebEngineTouchHandleProvider *touchHandleProvider = @@ -1470,6 +1473,7 @@ QQuickWebEngineViewPrivate::createTouchHandleDelegate(const QMap &i engine->imageProvider(QQuickWebEngineTouchHandleProvider::identifier())); Q_ASSERT(touchHandleProvider); touchHandleProvider->init(images); + handle = new QQuickWebEngineTouchHandle(); handle->setItem(item, true); } return handle; -- cgit v1.2.3