summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2018-01-09 16:15:43 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-01-24 18:18:38 +0000
commita96d1fdd51a5544bab52e5dbf176d31865f0542a (patch)
tree199df3dcb9a98a97852c4a368ea0920643ebfacf
parent7911a4f0480e3e5371515f211601b69606e32d50 (diff)
Fix random crashes on exit
Destroy WebContentsDelegateQt before WebContents, since it references already partly deleted WebContentsAdapterClient object. This prevents calls by navigation handling on already destructed web contents adapter client. Task-number: QTBUG-65647 Task-number: QTBUG-47945 Change-Id: I0ed5887b337a43ab89ecbfe05130691b5f1f37ec Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/core/web_contents_adapter.cpp2
-rw-r--r--src/core/web_contents_delegate_qt.cpp7
-rw-r--r--src/core/web_contents_delegate_qt.h2
3 files changed, 8 insertions, 3 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 5850b07b5..dc36b98c4 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -363,8 +363,6 @@ WebContentsAdapterPrivate::WebContentsAdapterPrivate()
WebContentsAdapterPrivate::~WebContentsAdapterPrivate()
{
- // Destroy the WebContents first
- webContents.reset();
}
QSharedPointer<WebContentsAdapter> WebContentsAdapter::createFromSerializedNavigationHistory(QDataStream &input, WebContentsAdapterClient *adapterClient)
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index f51a6dff3..db05fae4b 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -109,6 +109,13 @@ WebContentsDelegateQt::WebContentsDelegateQt(content::WebContents *webContents,
Observe(webContents);
}
+WebContentsDelegateQt::~WebContentsDelegateQt()
+{
+ // The destruction of this object should take place before
+ // WebContents destruction since WebContentsAdapterClient
+ // might be already deleted.
+}
+
content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents *source, const content::OpenURLParams &params)
{
content::WebContents *target = source;
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 8440ec053..2ebdb2ffc 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -92,7 +92,7 @@ class WebContentsDelegateQt : public content::WebContentsDelegate
{
public:
WebContentsDelegateQt(content::WebContents*, WebContentsAdapterClient *adapterClient);
- ~WebContentsDelegateQt() { Q_ASSERT(m_loadingErrorFrameList.isEmpty()); }
+ ~WebContentsDelegateQt();
QString lastSearchedString() const { return m_lastSearchedString; }
void setLastSearchedString(const QString &s) { m_lastSearchedString = s; }
int lastReceivedFindReply() const { return m_lastReceivedFindReply; }