From fd331a5b3a122393cd697a8b856dd52cfd31d698 Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 9 Jul 2014 15:03:35 +0200 Subject: QUrl: fromLocalFile(QString()) should lead to an empty URL. This is much more useful than the URL "file:", it allows to use "empty path" and "empty URL" for the same meaning (e.g. not set). QFileDialog actually uses "file:" though, as the URL for the "My Computer" item in the sidebar. This patch preserves that. [ChangeLog][QtCore][QUrl] QUrl::fromLocalFile now returns an empty URL if the input string is empty. Change-Id: Ib5ce1a3cdf5f229368e5bcd83c62c1d1ac9f8a17 Reviewed-by: Thiago Macieira --- tests/auto/corelib/io/qurl/tst_qurl.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/auto/corelib/io/qurl') diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 28b68dc750..ac4be31d0e 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -237,6 +237,11 @@ void tst_QUrl::constructing() QVERIFY(url == url); QVERIFY(!(url < url)); + QUrl fromLocal = QUrl::fromLocalFile(QString()); + QVERIFY(!fromLocal.isValid()); + QVERIFY(fromLocal.isEmpty()); + QCOMPARE(fromLocal.toString(), QString()); + QUrl justHost("qt-project.org"); QVERIFY(!justHost.isEmpty()); QVERIFY(justHost.host().isEmpty()); -- cgit v1.2.3