diff options
author | Christian Strømme <[email protected]> | 2015-05-29 12:23:29 +0200 |
---|---|---|
committer | Christian Stromme <[email protected]> | 2015-06-03 15:13:20 +0000 |
commit | c73251113d96119e5b937f81bbacfbcff2ef94cb (patch) | |
tree | 6dff28ea22fcc38f6bad10a6d319aac7b99fb666 | |
parent | 9b57e2f1765c0b4db6c3a9edf4277fc784a245f7 (diff) |
Fix crash on destruction of QWebView instances.v5.5.0
The QWebView and QWebViewPrivate class are now in the object tree and
will therefore be delete once their parent is destroyed.
This change removes the QScopedPointers that used to manage the
lifetime of the webview instances.
Task-number: QTBUG-46286
Change-Id: I2d7f12b317770113e5b35c14b60df7442aa3e68e
Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
-rw-r--r-- | src/webview/qquickwebview.cpp | 14 | ||||
-rw-r--r-- | src/webview/qquickwebview.h | 2 | ||||
-rw-r--r-- | src/webview/qwebview_android.cpp | 3 | ||||
-rw-r--r-- | src/webview/qwebview_osx.mm | 2 | ||||
-rw-r--r-- | src/webview/qwebview_p.h | 2 |
5 files changed, 13 insertions, 10 deletions
diff --git a/src/webview/qquickwebview.cpp b/src/webview/qquickwebview.cpp index 66cbaf8..270da36 100644 --- a/src/webview/qquickwebview.cpp +++ b/src/webview/qquickwebview.cpp @@ -90,13 +90,13 @@ QQuickWebView::QQuickWebView(QQuickItem *parent) : QQuickViewController(parent) , m_webView(new QWebView(this)) { - setView(m_webView.data()); - connect(m_webView.data(), &QWebView::titleChanged, this, &QQuickWebView::titleChanged); - connect(m_webView.data(), &QWebView::urlChanged, this, &QQuickWebView::urlChanged); - connect(m_webView.data(), &QWebView::loadProgressChanged, this, &QQuickWebView::loadProgressChanged); - connect(m_webView.data(), &QWebView::loadingChanged, this, &QQuickWebView::onLoadingChanged); - connect(m_webView.data(), &QWebView::requestFocus, this, &QQuickWebView::onFocusRequest); - connect(m_webView.data(), &QWebView::javaScriptResult, this, &QQuickWebView::onRunJavaScriptResult); + setView(m_webView); + connect(m_webView, &QWebView::titleChanged, this, &QQuickWebView::titleChanged); + connect(m_webView, &QWebView::urlChanged, this, &QQuickWebView::urlChanged); + connect(m_webView, &QWebView::loadProgressChanged, this, &QQuickWebView::loadProgressChanged); + connect(m_webView, &QWebView::loadingChanged, this, &QQuickWebView::onLoadingChanged); + connect(m_webView, &QWebView::requestFocus, this, &QQuickWebView::onFocusRequest); + connect(m_webView, &QWebView::javaScriptResult, this, &QQuickWebView::onRunJavaScriptResult); } QQuickWebView::~QQuickWebView() diff --git a/src/webview/qquickwebview.h b/src/webview/qquickwebview.h index d59b515..ed20664 100644 --- a/src/webview/qquickwebview.h +++ b/src/webview/qquickwebview.h @@ -112,7 +112,7 @@ private Q_SLOTS: void onLoadingChanged(const QWebViewLoadRequestPrivate &loadRequest); private: - QScopedPointer<QWebView> m_webView; + QWebView* m_webView; }; QT_END_NAMESPACE diff --git a/src/webview/qwebview_android.cpp b/src/webview/qwebview_android.cpp index 76e7288..be5ab6d 100644 --- a/src/webview/qwebview_android.cpp +++ b/src/webview/qwebview_android.cpp @@ -128,7 +128,8 @@ QAndroidWebViewPrivate::QAndroidWebViewPrivate(QObject *p) QAndroidWebViewPrivate::~QAndroidWebViewPrivate() { g_webViews->take(m_id); - delete m_window; + if (m_window != 0 && m_window->parent() == 0) + delete m_window; } QUrl QAndroidWebViewPrivate::url() const diff --git a/src/webview/qwebview_osx.mm b/src/webview/qwebview_osx.mm index b4f05e5..60725e7 100644 --- a/src/webview/qwebview_osx.mm +++ b/src/webview/qwebview_osx.mm @@ -143,6 +143,8 @@ QOsxWebViewPrivate::~QOsxWebViewPrivate() { [webView.frameLoadDelegate release]; [webView release]; + if (m_window != 0 && m_window->parent() == 0) + delete m_window; } QUrl QOsxWebViewPrivate::url() const diff --git a/src/webview/qwebview_p.h b/src/webview/qwebview_p.h index baeda60..b7d5fe9 100644 --- a/src/webview/qwebview_p.h +++ b/src/webview/qwebview_p.h @@ -128,7 +128,7 @@ private: int m_progress; Q_DECLARE_PRIVATE(QWebView) - QScopedPointer<QWebViewPrivate> d_ptr; + QWebViewPrivate *d_ptr; }; QT_END_NAMESPACE |