summaryrefslogtreecommitdiffstats
path: root/src/webengine/api/qquickwebenginedownloaditem.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@theqtcompany.com>2015-09-03 13:20:24 +0200
committerKai Koehne <kai.koehne@theqtcompany.com>2015-09-04 14:24:03 +0000
commit003924d46e5f886eca1fa3fd220e3d1b652322fb (patch)
tree19dac2aaaa3bbeac38deedaedc910a4a0ab58be8 /src/webengine/api/qquickwebenginedownloaditem.cpp
parent3f9c6206450b0c67a5dadfe0da023ec6be7d1743 (diff)
Break destruction cycle between DownloadItem and WebEngineProfile
All QQWebEngineDownloadItem objects are destructed as child objects of QQWebEngineProfile. However, they try to 'call back' to the already half-destructed QQWebEngineProfile object to unregister themselves. Avoid this by tracking the lifetime of the QWebEngineProfile with a QPointer. Task-number: QTBUG-48088 Change-Id: Ie6a76440ad9f37d7cbc38b4ce35bf5da785d0e2a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'src/webengine/api/qquickwebenginedownloaditem.cpp')
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp
index 89fe688a4..e04cff2c4 100644
--- a/src/webengine/api/qquickwebenginedownloaditem.cpp
+++ b/src/webengine/api/qquickwebenginedownloaditem.cpp
@@ -58,7 +58,7 @@ static inline QQuickWebEngineDownloadItem::DownloadState toDownloadState(int sta
}
}
-QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfilePrivate *p)
+QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p)
: profile(p)
, downloadId(-1)
, downloadState(QQuickWebEngineDownloadItem::DownloadCancelled)
@@ -69,7 +69,8 @@ QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWeb
QQuickWebEngineDownloadItemPrivate::~QQuickWebEngineDownloadItemPrivate()
{
- profile->downloadDestroyed(downloadId);
+ if (profile)
+ profile->d_ptr->downloadDestroyed(downloadId);
}
/*!
@@ -150,8 +151,10 @@ void QQuickWebEngineDownloadItem::cancel()
// We directly cancel the download if the user cancels before
// it even started, so no need to notify the profile here.
- if (state == QQuickWebEngineDownloadItem::DownloadInProgress)
- d->profile->cancelDownload(d->downloadId);
+ if (state == QQuickWebEngineDownloadItem::DownloadInProgress) {
+ if (d->profile)
+ d->profile->d_ptr->cancelDownload(d->downloadId);
+ }
}
/*!