summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-03-29 17:32:58 -0300
committerQt by Nokia <qt-info@nokia.com>2012-03-30 01:19:59 +0200
commitffd20af339c64bf3af7983d20b029724a67f0734 (patch)
tree94feb987c82005ee40b307aa20111ec095740011
parent7f20dce264c6f982e84c3b5d60f3ffbf6341c908 (diff)
Revert to Qt4 behaviour that QUrl().isValid() == false
There are probably lots of places that rely on that behaviour, so go back to what it was. Change-Id: I4d1503a0ee105a50cdfaab52d9a5862a02c70757 Reviewed-by: David Faure <faure@kde.org>
-rw-r--r--src/corelib/io/qurl.cpp16
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp6
2 files changed, 6 insertions, 16 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 8675d03d85..634a613ade 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -1379,7 +1379,7 @@ QUrl::~QUrl()
}
/*!
- Returns true if the URL is valid; otherwise returns false.
+ Returns true if the URL is non-empty and valid; otherwise returns false.
The URL is run through a conformance test. Every part of the URL
must conform to the standard encoding rules of the URI standard
@@ -1389,7 +1389,7 @@ QUrl::~QUrl()
*/
bool QUrl::isValid() const
{
- if (!d) return true;
+ if (isEmpty()) return false;
return d->sectionHasError == 0;
}
@@ -1399,17 +1399,7 @@ bool QUrl::isValid() const
bool QUrl::isEmpty() const
{
if (!d) return true;
-
- // cannot use sectionIsPresent here
- // we may have only empty sections present
- return d->scheme.isEmpty()
- && d->userName.isEmpty()
- && d->password.isEmpty()
- && d->host.isEmpty()
- && d->port == -1
- && d->path.isEmpty()
- && d->query.isEmpty()
- && d->fragment.isEmpty();
+ return d->isEmpty();
}
/*!
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 12344f9909..852eb0ab97 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -206,7 +206,7 @@ void tst_QUrl::getSetCheck()
void tst_QUrl::constructing()
{
QUrl url;
- QVERIFY(url.isValid());
+ QVERIFY(!url.isValid());
QVERIFY(url.isEmpty());
QCOMPARE(url.port(), -1);
QCOMPARE(url.toString(), QString());
@@ -1230,7 +1230,6 @@ void tst_QUrl::compat_isValid_02_data()
QString n = "";
- QTest::newRow( "ok_00" ) << n << n << n << n << -1 << n << (bool)true;
QTest::newRow( "ok_01" ) << n << n << n << n << -1 << QString("path") << (bool)true;
QTest::newRow( "ok_02" ) << QString("ftp") << n << n << QString("ftp.qt.nokia.com") << -1 << n << (bool)true;
QTest::newRow( "ok_03" ) << QString("ftp") << QString("foo") << n << QString("ftp.qt.nokia.com") << -1 << n << (bool)true;
@@ -1239,6 +1238,7 @@ void tst_QUrl::compat_isValid_02_data()
QTest::newRow( "ok_06" ) << QString("ftp") << QString("foo") << n << QString("ftp.qt.nokia.com") << -1 << QString("path") << (bool)true;
QTest::newRow( "ok_07" ) << QString("ftp") << QString("foo") << QString("bar") << QString("ftp.qt.nokia.com") << -1 << QString("path")<< (bool)true;
+ QTest::newRow( "err_01" ) << n << n << n << n << -1 << n << (bool)false;
QTest::newRow( "err_02" ) << QString("ftp") << n << n << n << -1 << n << (bool)true;
QTest::newRow( "err_03" ) << n << QString("foo") << n << n << -1 << n << (bool)true;
QTest::newRow( "err_04" ) << n << n << QString("bar") << n << -1 << n << (bool)true;
@@ -1693,7 +1693,7 @@ void tst_QUrl::schemeValidator_data()
QTest::addColumn<bool>("result");
QTest::addColumn<QString>("toString");
- QTest::newRow("empty") << QByteArray() << true << QString();
+ QTest::newRow("empty") << QByteArray() << false << QString();
// ftp
QTest::newRow("ftp:") << QByteArray("ftp:") << true << QString("ftp:");