diff options
author | Aapo Haapanen <ext-aapo.haapanen@nokia.com> | 2012-01-26 14:11:40 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-02 09:05:21 (GMT) |
commit | 182acb541a7b8ac0edca842fdc867751df723f50 (patch) | |
tree | 5d173cd2ece4cbe5aa397c98dedadcdf46349b99 /src | |
parent | fb7e4ff9855bab4b06583f65198247ccfcc6599a (diff) | |
download | Qt-182acb541a7b8ac0edca842fdc867751df723f50.zip Qt-182acb541a7b8ac0edca842fdc867751df723f50.tar.gz Qt-182acb541a7b8ac0edca842fdc867751df723f50.tar.bz2 |
Change QUrl::toLocalFile to return path for relative urls
This change reverts the behaviour of QUrl::toLocalFile to the state
it was before 4.8. After this change the function returns the path if
the url is relative. Before this change an empty QString was returned.
A relative url can refer to a local file, but that can't be determined
from the url alone. Thus, it makes sense to return the path for such
urls.
Added documentation to explain that the function works like this to
maintain backward compatability in 4.x, but the handling of relative
URLs will change in 5.0.
Task-number: QTBUG-19827
Change-Id: I8bb8f4603a5936c0359afc1b6ff98824fad6cbc9
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qurl.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 4de8fe8..51631ff 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -6155,12 +6155,19 @@ QUrl QUrl::fromLocalFile(const QString &localFile) returned value in the form found on SMB networks (for example, "//servername/path/to/file.txt"). + If this is a relative URL, in Qt 4.x this function returns the path to + maintain backward compatability. This will change from 5.0 onwards. Then + the path is returned only for URLs where the scheme is "file", and for + all other URLs an empty string is returned. + \sa fromLocalFile(), isLocalFile() */ QString QUrl::toLocalFile() const { + if (!d) return QString(); + // the call to isLocalFile() also ensures that we're parsed - if (!isLocalFile()) + if (!isLocalFile() && !d->scheme.isEmpty()) return QString(); QString tmp; |