From ea503a2f07f2505d8d91a7d7999a1fb1b1d6b57c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 30 Jun 2016 16:22:33 +0200 Subject: Let script collection hold a reference to the adapter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While the script collection always follows a page, it is safer to have both hold a reference to the web-contents adapter, so it doesn't get deleted while adapters are being changed. Change-Id: I21e268f7228f13702468df61e0032bdf2f99873a Reviewed-by: Michael BrĂ¼ning --- .../api/qwebenginescriptcollection.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/webenginewidgets/api/qwebenginescriptcollection.cpp') diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.cpp b/src/webenginewidgets/api/qwebenginescriptcollection.cpp index 117c35b5a..8d581b60a 100644 --- a/src/webenginewidgets/api/qwebenginescriptcollection.cpp +++ b/src/webenginewidgets/api/qwebenginescriptcollection.cpp @@ -172,32 +172,32 @@ QWebEngineScriptCollectionPrivate::QWebEngineScriptCollectionPrivate(QtWebEngine int QWebEngineScriptCollectionPrivate::count() const { - return m_scriptController->registeredScripts(m_contents).count(); + return m_scriptController->registeredScripts(m_contents.data()).count(); } bool QWebEngineScriptCollectionPrivate::contains(const QWebEngineScript &s) const { - return m_scriptController->containsUserScript(*s.d, m_contents); + return m_scriptController->containsUserScript(*s.d, m_contents.data()); } void QWebEngineScriptCollectionPrivate::insert(const QWebEngineScript &script) { if (!script.d) return; - m_scriptController->addUserScript(*script.d, m_contents); + m_scriptController->addUserScript(*script.d, m_contents.data()); } bool QWebEngineScriptCollectionPrivate::remove(const QWebEngineScript &script) { if (!script.d) return false; - return m_scriptController->removeUserScript(*script.d, m_contents); + return m_scriptController->removeUserScript(*script.d, m_contents.data()); } QList QWebEngineScriptCollectionPrivate::toList(const QString &scriptName) const { QList ret; - Q_FOREACH (const UserScript &script, m_scriptController->registeredScripts(m_contents)) + Q_FOREACH (const UserScript &script, m_scriptController->registeredScripts(m_contents.data())) if (scriptName.isNull() || scriptName == script.name()) ret.append(QWebEngineScript(script)); return ret; @@ -205,7 +205,7 @@ QList QWebEngineScriptCollectionPrivate::toList(const QString QWebEngineScript QWebEngineScriptCollectionPrivate::find(const QString &name) const { - Q_FOREACH (const UserScript &script, m_scriptController->registeredScripts(m_contents)) + Q_FOREACH (const UserScript &script, m_scriptController->registeredScripts(m_contents.data())) if (name == script.name()) return QWebEngineScript(script); return QWebEngineScript(); @@ -213,12 +213,12 @@ QWebEngineScript QWebEngineScriptCollectionPrivate::find(const QString &name) co void QWebEngineScriptCollectionPrivate::clear() { - m_scriptController->clearAllScripts(m_contents); + m_scriptController->clearAllScripts(m_contents.data()); } void QWebEngineScriptCollectionPrivate::reserve(int capacity) { - m_scriptController->reserve(m_contents, capacity); + m_scriptController->reserve(m_contents.data(), capacity); } void QWebEngineScriptCollectionPrivate::rebindToContents(QtWebEngineCore::WebContentsAdapter *page) @@ -227,7 +227,7 @@ void QWebEngineScriptCollectionPrivate::rebindToContents(QtWebEngineCore::WebCon Q_ASSERT(page); Q_ASSERT(m_contents != page); - Q_FOREACH (const UserScript &script, m_scriptController->registeredScripts(m_contents)) { + Q_FOREACH (const UserScript &script, m_scriptController->registeredScripts(m_contents.data())) { m_scriptController->addUserScript(script, page); } m_contents = page; -- cgit v1.2.3