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>
This commit is contained in:
Thiago Macieira 2012-03-29 17:32:58 -03:00 committed by Qt by Nokia
parent 7f20dce264
commit ffd20af339
2 changed files with 6 additions and 16 deletions

View File

@ -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();
}
/*!

View File

@ -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:");