diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2013-01-28 10:33:23 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-28 15:52:38 +0100 |
commit | d65f551ec3dd28be38d75a893f74919dfa27071e (patch) | |
tree | 877051dae44a10ce489d5b122d2085b0cd3d828f | |
parent | 81cb91bb6b34f10cb4f1e8da9a0dccc6a9b4a2c4 (diff) | |
download | qtwebkit-d65f551ec3dd28be38d75a893f74919dfa27071e.tar.gz |
[Qt] Fix a crash when the QQuickWebPage is destroyed between the scene graph sync and render.
https://bugs.webkit.org/show_bug.cgi?id=106018
Reviewed by Simon Hausmann.
The main and rendering threads are only guaranteed to be synchronised in
the updatePaintNode call. In every other cases, QQuickItems cannot be
safely accessed from the rendering thread.
Do as the first patch version in
https://bugs.webkit.org/show_bug.cgi?id=104574 was doing and copy the
ratio value directly to fix the issue.
Also add a note about the threading issue in QQuickWebPage::updatePaintNode.
* UIProcess/API/qt/qquickwebpage.cpp:
(QQuickWebPage::updatePaintNode):
* UIProcess/qt/QtWebPageSGNode.cpp:
(WebKit::QtWebPageSGNode::QtWebPageSGNode):
* UIProcess/qt/QtWebPageSGNode.h:
(QtWebPageSGNode):
(WebKit::QtWebPageSGNode::devicePixelRatio):
(WebKit::QtWebPageSGNode::setDevicePixelRatio):
Change-Id: I2ef35f357c56c251033573d4435ddd7768a4422f
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
-rw-r--r-- | Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp | 7 | ||||
-rw-r--r-- | Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp | 11 | ||||
-rw-r--r-- | Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h | 7 |
3 files changed, 11 insertions, 14 deletions
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp index a1f35ae47..a7d74b2e2 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp @@ -91,15 +91,18 @@ QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) if (window && d->webPageProxy->deviceScaleFactor() != window->devicePixelRatio()) { d->webPageProxy->setIntrinsicDeviceScaleFactor(window->devicePixelRatio()); - d->viewportItem->experimental()->test()->devicePixelRatioChanged(); + // This signal is queued since if we are running a threaded renderer. This might cause failures + // if tests are reading the new value between the property change and the signal emission. + emit d->viewportItem->experimental()->test()->devicePixelRatioChanged(); } if (!node) - node = new QtWebPageSGNode(this); + node = new QtWebPageSGNode; node->setRenderer(renderer); node->setScale(d->contentsScale); + node->setDevicePixelRatio(window->devicePixelRatio()); QColor backgroundColor = d->webPageProxy->drawsTransparentBackground() ? Qt::transparent : Qt::white; QRectF backgroundRect(QPointF(0, 0), d->contentsSize); node->setBackground(backgroundRect, backgroundColor); diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp index d72980c05..7b6c1ee87 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp @@ -126,10 +126,10 @@ private: RefPtr<LayerTreeRenderer> m_renderer; }; -QtWebPageSGNode::QtWebPageSGNode(const QQuickItem* item) +QtWebPageSGNode::QtWebPageSGNode() : m_contentsNode(0) , m_backgroundNode(new QSGSimpleRectNode) - , m_item(item) + , m_devicePixelRatio(1) { appendChildNode(m_backgroundNode); } @@ -147,13 +147,6 @@ void QtWebPageSGNode::setScale(float scale) setMatrix(matrix); } -qreal QtWebPageSGNode::devicePixelRatio() const -{ - if (const QWindow* window = m_item->window()) - return window->devicePixelRatio(); - return 1; -} - void QtWebPageSGNode::setRenderer(PassRefPtr<LayerTreeRenderer> renderer) { if (m_contentsNode && m_contentsNode->layerTreeRenderer() == renderer) diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h index 368df704a..1bcc28e43 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h +++ b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h @@ -36,16 +36,17 @@ class LayerTreeRenderer; class QtWebPageSGNode : public QSGTransformNode { public: - QtWebPageSGNode(const QQuickItem*); + QtWebPageSGNode(); void setBackground(const QRectF&, const QColor&); void setScale(float); void setRenderer(PassRefPtr<LayerTreeRenderer>); - qreal devicePixelRatio() const; + qreal devicePixelRatio() const { return m_devicePixelRatio; } + void setDevicePixelRatio(qreal devicePixelRatio) { m_devicePixelRatio = devicePixelRatio; } private: ContentsSGNode* m_contentsNode; QSGSimpleRectNode* m_backgroundNode; - const QQuickItem* const m_item; + qreal m_devicePixelRatio; }; } // namespace WebKit |