summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-01-07 12:57:23 +0100
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-01-08 19:08:20 +0000
commitf04389b65574a4ba97a69c5feb6004dcfb171ba7 (patch)
tree6737c08585862ba211939a888b5118e44b0d4058
parent687fe11d738238c17f9c6dbfd57d15ff2668272f (diff)
Avoid creating contents adapter when setting background color
Moves the initial setting of a non-default background color to initialization, so we don't need to force the creation of the contents adapter if a WebView component sets the background color. Change-Id: Iabd0146e6072653962877162d66da58154faf770 Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com> Reviewed-by: Jocelyn Turcotte (Woboq GmbH) <jturcotte@woboq.com>
-rw-r--r--src/webengine/api/qquickwebengineview.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 32800dd70..fd758bea2 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -707,6 +707,9 @@ void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContent
// associate the webChannel with the new adapter
if (qmlWebChannel)
adapter->setWebChannel(qmlWebChannel);
+ // set initial background color if non-default
+ if (m_backgroundColor != Qt::white)
+ adapter->backgroundColorChanged();
// re-bind the userscrips to the new adapter
Q_FOREACH (QQuickWebEngineScript *script, m_userScripts)
@@ -747,6 +750,8 @@ void QQuickWebEngineViewPrivate::ensureContentsAdapter()
if (!adapter) {
adapter = new WebContentsAdapter();
adapter->initialize(this);
+ if (m_backgroundColor != Qt::white)
+ adapter->backgroundColorChanged();
if (explicitUrl.isValid())
adapter->load(explicitUrl);
// push down the page's user scripts
@@ -1063,8 +1068,8 @@ void QQuickWebEngineView::setBackgroundColor(const QColor &color)
if (color == d->m_backgroundColor)
return;
d->m_backgroundColor = color;
- d->ensureContentsAdapter();
- d->adapter->backgroundColorChanged();
+ if (d->adapter)
+ d->adapter->backgroundColorChanged();
emit backgroundColorChanged();
}