From 808ca6e6917cf17e4c30fcd3ac609164b36594cc Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 20 Jun 2016 11:15:20 +0200 Subject: Prevent a crash after having downloaded a file Since the profile owns the QWebEngineDownloadItem then it is likely that it will still be around when the QWebEngineProfile is deleted. As the QWebEngineDownloadItem is a child of the QWebEngineProfile then it will try to delete it when deleting the QWebEngineProfile which means it cannot trigger a function call into QWebEngineProfilePrivate. Change-Id: I51077a7857fb49a6708224a9e9942d17de6f6778 Reviewed-by: Allan Sandfeld Jensen --- .../widgets/qwebengineprofile/tst_qwebengineprofile.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp index 287e2364a..23a56a9cb 100644 --- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp +++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp @@ -42,6 +42,7 @@ #include #include #include +#include class tst_QWebEngineProfile : public QObject { @@ -54,6 +55,7 @@ private Q_SLOTS: void urlSchemeHandlerFailRequest(); void customUserAgent(); void httpAcceptLanguage(); + void downloadItem(); }; void tst_QWebEngineProfile::defaultProfile() @@ -245,5 +247,16 @@ void tst_QWebEngineProfile::httpAcceptLanguage() QCOMPARE(evaluateJavaScriptSync(&page, QStringLiteral("navigator.languages")).toStringList(), QStringList(testLang)); } +void tst_QWebEngineProfile::downloadItem() +{ + qRegisterMetaType(); + QWebEngineProfile testProfile; + QWebEnginePage page(&testProfile); + QSignalSpy downloadSpy(&testProfile, SIGNAL(downloadRequested(QWebEngineDownloadItem *))); + connect(&testProfile, &QWebEngineProfile::downloadRequested, this, [=] (QWebEngineDownloadItem *item) { item->accept(); }); + page.load(QUrl::fromLocalFile(QCoreApplication::applicationFilePath())); + QTRY_COMPARE(downloadSpy.count(), 1); +} + QTEST_MAIN(tst_QWebEngineProfile) #include "tst_qwebengineprofile.moc" -- cgit v1.2.3