summaryrefslogtreecommitdiffstats
path: root/src/webengine
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem.cpp11
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p_p.h6
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp2
-rw-r--r--src/webengine/api/qquickwebengineprofile_p.h2
4 files changed, 14 insertions, 7 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);
+ }
}
/*!
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
index c858693e0..230f322b5 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h
+++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
@@ -50,19 +50,21 @@
#include "browser_context_adapter_client.h"
#include "qquickwebenginedownloaditem_p.h"
+#include "qquickwebengineprofile_p.h"
#include <private/qtwebengineglobal_p.h>
#include <QString>
+#include <QPointer>
QT_BEGIN_NAMESPACE
class QQuickWebEngineProfilePrivate;
class QQuickWebEngineDownloadItemPrivate {
QQuickWebEngineDownloadItem *q_ptr;
- QQuickWebEngineProfilePrivate* profile;
+ QPointer<QQuickWebEngineProfile> profile;
friend class QQuickWebEngineProfilePrivate;
public:
Q_DECLARE_PUBLIC(QQuickWebEngineDownloadItem)
- QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfilePrivate *p);
+ QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p);
~QQuickWebEngineDownloadItemPrivate();
quint32 downloadId;
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
index bff640d32..68884f967 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -85,7 +85,7 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
Q_Q(QQuickWebEngineProfile);
Q_ASSERT(!m_ongoingDownloads.contains(info.id));
- QQuickWebEngineDownloadItemPrivate *itemPrivate = new QQuickWebEngineDownloadItemPrivate(this);
+ QQuickWebEngineDownloadItemPrivate *itemPrivate = new QQuickWebEngineDownloadItemPrivate(q);
itemPrivate->downloadId = info.id;
itemPrivate->downloadState = QQuickWebEngineDownloadItem::DownloadRequested;
itemPrivate->totalBytes = info.totalBytes;
diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h
index d07428cab..323721bd0 100644
--- a/src/webengine/api/qquickwebengineprofile_p.h
+++ b/src/webengine/api/qquickwebengineprofile_p.h
@@ -138,6 +138,8 @@ private:
friend class QQuickWebEngineSettings;
friend class QQuickWebEngineSingleton;
friend class QQuickWebEngineViewPrivate;
+ friend class QQuickWebEngineDownloadItem;
+ friend class QQuickWebEngineDownloadItemPrivate;
QScopedPointer<QQuickWebEngineProfilePrivate> d_ptr;
};