summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-03-19 15:59:05 +0100
committerAndy Shaw <andy.shaw@qt.io>2020-03-20 07:28:52 +0100
commitdf93624cc31e9da29532eed1d86c9f172575355a (patch)
treec557d069ae6a4dcffc1da0267af5abe67c0d663d /src
parent12420abbfa66e03938571528647be6f6d9034aa7 (diff)
Set the httpUserAgent after the component has been completed
Since httpUserAgent can be set as a property then it should account for the fact that init() has not yet been called. So ensure that the httpUserAgent is set on the profile created when init() is called. Fixes: QTBUG-82778 Change-Id: I072676e719eedcb0fbc8024f3e902fd1b7073a3e Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/webengine/qwebenginewebview.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/plugins/webengine/qwebenginewebview.cpp b/src/plugins/webengine/qwebenginewebview.cpp
index f16371d..7870b3a 100644
--- a/src/plugins/webengine/qwebenginewebview.cpp
+++ b/src/plugins/webengine/qwebenginewebview.cpp
@@ -81,8 +81,11 @@ QString QWebEngineWebViewPrivate::httpUserAgent() const
void QWebEngineWebViewPrivate::setHttpUserAgent(const QString &userAgent)
{
- m_profile->setHttpUserAgent(userAgent);
- Q_EMIT httpUserAgentChanged(userAgent);
+ m_httpUserAgent = userAgent;
+ if (m_profile) {
+ m_profile->setHttpUserAgent(userAgent);
+ Q_EMIT httpUserAgentChanged(userAgent);
+ }
}
QUrl QWebEngineWebViewPrivate::url() const
@@ -255,7 +258,12 @@ void QWebEngineWebViewPrivate::QQuickWebEngineViewPtr::init() const
Q_ASSERT(webEngineView);
QQuickWebEngineProfile *profile = webEngineView->profile();
m_parent->m_profile = profile;
- m_parent->m_httpUserAgent = profile->httpUserAgent();
+ // When the httpUserAgent is set as a property then it will be set before
+ // init() is called
+ if (m_parent->m_httpUserAgent.isEmpty())
+ m_parent->m_httpUserAgent = profile->httpUserAgent();
+ else
+ profile->setHttpUserAgent(m_parent->m_httpUserAgent);
QObject::connect(webEngineView, &QQuickWebEngineView::urlChanged, m_parent, &QWebEngineWebViewPrivate::q_urlChanged);
QObject::connect(webEngineView, &QQuickWebEngineView::loadProgressChanged, m_parent, &QWebEngineWebViewPrivate::q_loadProgressChanged);
QObject::connect(webEngineView, &QQuickWebEngineView::loadingChanged, m_parent, &QWebEngineWebViewPrivate::q_loadingChanged);