summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-08-17 15:18:57 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-08-21 22:24:46 +0000
commitf589b8b411f1049f6f2f701478e0c38c72ad824a (patch)
tree958c4c3f2d2082c34e1515cf1e6a178d9b43d1eb
parente8d4115c43665fb6e567e639fce3924082ae6450 (diff)
Fix crash on changing persistent storage path
The deletion of HttpNetworkSession references the old HttpServerProperties so delete the session before we replace the properties. Task-number: QTBUG-55322 Change-Id: I420dc0523fda44423adaa5f4f0fa1df9ade4b584 Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
-rw-r--r--src/core/url_request_context_getter_qt.cpp1
-rw-r--r--tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp20
2 files changed, 21 insertions, 0 deletions
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp
index 959dd3d95..42c8db280 100644
--- a/src/core/url_request_context_getter_qt.cpp
+++ b/src/core/url_request_context_getter_qt.cpp
@@ -216,6 +216,7 @@ void URLRequestContextGetterQt::generateStorage()
cancelAllUrlRequests();
// we need to get rid of dangling pointer due to coming storage deletion
m_urlRequestContext->set_http_transaction_factory(0);
+ m_httpNetworkSession.reset();
}
m_storage.reset(new net::URLRequestContextStorage(m_urlRequestContext.get()));
diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
index 579a0f776..093bc2e43 100644
--- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
+++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
@@ -52,6 +52,7 @@ private Q_SLOTS:
void customUserAgent();
void httpAcceptLanguage();
void downloadItem();
+ void changePersistentPath();
};
void tst_QWebEngineProfile::defaultProfile()
@@ -375,5 +376,24 @@ void tst_QWebEngineProfile::downloadItem()
QTRY_COMPARE(downloadSpy.count(), 1);
}
+void tst_QWebEngineProfile::changePersistentPath()
+{
+ QWebEngineProfile testProfile(QStringLiteral("Test"));
+ const QString oldPath = testProfile.persistentStoragePath();
+ QVERIFY(oldPath.endsWith(QStringLiteral("Test")));
+
+ // Make sure the profile has been used and the url-request-context-getter instantiated:
+ QWebEnginePage page(&testProfile);
+ QSignalSpy loadFinishedSpy(&page, SIGNAL(loadFinished(bool)));
+ page.load(QUrl("http://qt-project.org"));
+ if (!loadFinishedSpy.wait(10000) || !loadFinishedSpy.at(0).at(0).toBool())
+ QSKIP("Couldn't load page from network, skipping test.");
+
+ // Test we do not crash (QTBUG-55322):
+ testProfile.setPersistentStoragePath(oldPath + QLatin1Char('2'));
+ const QString newPath = testProfile.persistentStoragePath();
+ QVERIFY(newPath.endsWith(QStringLiteral("Test2")));
+}
+
QTEST_MAIN(tst_QWebEngineProfile)
#include "tst_qwebengineprofile.moc"