diff options
| author | Vladimir Belyavsky <belyavskyv@gmail.com> | 2025-10-29 13:24:12 +0300 |
|---|---|---|
| committer | Vladimir Belyavsky <belyavskyv@gmail.com> | 2025-11-27 00:05:28 +0000 |
| commit | 9359185c706d99e06fd432f0dae21d09e5016321 (patch) | |
| tree | 5849f8607ac8a59f07600b126ef2c361487eda3c | |
| parent | 578d9b0c2940a64b431b30460fb6654dbc290106 (diff) | |
QQuickWebEngineView: handle null qmlEngine in navigationRequested()
Bail out earlier and do not crash in navigationRequested callback
when qmlEngine is null. This may happen when using WebEngineView e.g.
in a Loader, as the QML context data is cleared before the object is
destroyed and accordingly, before we unsubscribe from the callback.
Note this is band aid fix, as it is still unclear why this problem
did not occur here before (e.g. with Qt 6.8.3).
Task-number: QTBUG-137768
Pick-to: 6.10
Change-Id: I33bbaf4240511d20f0b839317fb496fd5b270006
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
| -rw-r--r-- | src/webenginequick/api/qquickwebengineview.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/webenginequick/api/qquickwebengineview.cpp b/src/webenginequick/api/qquickwebengineview.cpp index f0d972448..a2c8816bf 100644 --- a/src/webenginequick/api/qquickwebengineview.cpp +++ b/src/webenginequick/api/qquickwebengineview.cpp @@ -446,8 +446,14 @@ void QQuickWebEngineViewPrivate::contextMenuRequested(QWebEngineContextMenuReque void QQuickWebEngineViewPrivate::navigationRequested(int navigationType, const QUrl &url, bool &accepted, bool isMainFrame, bool hasFrameData) { Q_Q(QQuickWebEngineView); + + QQmlEngine *engine = qmlEngine(q); + if (!engine) + return; + auto request = new QWebEngineNavigationRequest(url, static_cast<QWebEngineNavigationRequest::NavigationType>(navigationType), isMainFrame, hasFrameData); - qmlEngine(q)->newQObject(request); + + engine->newQObject(request); Q_EMIT q->navigationRequested(request); accepted = request->isAccepted(); |
