diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-06-30 16:22:33 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-07-01 11:26:25 +0000 |
commit | ea503a2f07f2505d8d91a7d7999a1fb1b1d6b57c (patch) | |
tree | 94267598ac36bcf587ed4e54ed12d7c4b5749b46 /src/webenginewidgets/api/qwebenginescriptcollection.cpp | |
parent | 5b219fc20dbfe6090af45c1dbdb7ad50bc743ca1 (diff) |
Let script collection hold a reference to the adapter
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 <michael.bruning@qt.io>
Diffstat (limited to 'src/webenginewidgets/api/qwebenginescriptcollection.cpp')
-rw-r--r-- | src/webenginewidgets/api/qwebenginescriptcollection.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
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<QWebEngineScript> QWebEngineScriptCollectionPrivate::toList(const QString &scriptName) const { QList<QWebEngineScript> 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<QWebEngineScript> 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; |