From 089ee7094eabb2058b478f5d2f306a69f6c0b3bf Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 7 Jan 2010 10:32:33 +0100 Subject: Make an empty QUrl also be considered non-detached (d == 0). Reviewed-by: Trust Me --- src/corelib/io/qurl.cpp | 2 +- tests/auto/qurl/tst_qurl.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 1882e92..1ba5e3f 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -5928,7 +5928,7 @@ void QUrl::detach() */ bool QUrl::isDetached() const { - return !d || d->ref == 1; + return d && d->ref == 1; } diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 33812fe..ecd6f09 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -90,6 +90,7 @@ public slots: private slots: void getSetCheck(); void constructing(); + void isDetached(); void assignment(); void comparison(); void copying(); @@ -318,6 +319,25 @@ void tst_QUrl::constructing() QVERIFY(!buildUNC.isEmpty()); } +void tst_QUrl::isDetached() +{ + QUrl url; + QVERIFY(!url.isDetached()); + + url = "http://qt.nokia.com/"; + QVERIFY(url.isDetached()); + + url.clear(); + QVERIFY(!url.isDetached()); + + url.setHost("qt.nokia.com"); + QVERIFY(url.isDetached()); + + QUrl url2 = url; + QVERIFY(!url.isDetached()); + QVERIFY(!url2.isDetached()); +} + void tst_QUrl::assignment() { QUrl url("http://qt.nokia.com/"); -- cgit v0.12