diff --git a/src/core/statjob.h b/src/core/statjob.h --- a/src/core/statjob.h +++ b/src/core/statjob.h @@ -108,18 +108,20 @@ /** * @brief most local URL - * Call this in the slot connected to result, - * and only after making sure no error happened. - * @return the most local URL for the URL we were stat'ing. + * + * Call this in a slot connected to the result signal, and only after making sure no error + * happened. + * + * @return the most local URL for the URL we were stat'ing * * Sample usage: * * @code - * KIO::StatJob* job = KIO::mostLocalUrl("desktop:/foo"); + * KIO::StatJob *job = KIO::mostLocalUrl("desktop:/foo"); * job->uiDelegate()->setWindow(this); * connect(job, &KJob::result, this, &MyClass::slotMostLocalUrlResult); * [...] - * // and in the slot slotMostLocalUrlResult(KJob *job) + * // and in slotMostLocalUrlResult(KJob *job) * if (job->error()) { * [...] // doesn't exist * } else { diff --git a/src/core/statjob.cpp b/src/core/statjob.cpp --- a/src/core/statjob.cpp +++ b/src/core/statjob.cpp @@ -23,6 +23,7 @@ #include "job_p.h" #include "slave.h" #include "scheduler.h" +#include #include #include @@ -126,14 +127,18 @@ QUrl StatJob::mostLocalUrl() const { - if (!url().isLocalFile()) { + const QUrl _url = url(); + + if (_url.isLocalFile()) { + return _url; + } + + QString path; + if (KProtocolInfo::protocolClass(_url.scheme()) == QLatin1String(":local")) { const UDSEntry &udsEntry = d_func()->m_statResult; - const QString path = udsEntry.stringValue(KIO::UDSEntry::UDS_LOCAL_PATH); - if (!path.isEmpty()) { - return QUrl::fromLocalFile(path); - } + path = udsEntry.stringValue(KIO::UDSEntry::UDS_LOCAL_PATH); } - return url(); + return !path.isEmpty() ? QUrl::fromLocalFile(path) : _url; } void StatJobPrivate::start(Slave *slave) @@ -212,7 +217,7 @@ StatJob *KIO::mostLocalUrl(const QUrl &url, JobFlags flags) { StatJob *job = statDetails(url, StatJob::SourceSide, KIO::StatDefaultDetails, flags); - if (url.isLocalFile()) { + if (url.isLocalFile() || KProtocolInfo::protocolClass(url.scheme()) != QLatin1String(":local")) { QTimer::singleShot(0, job, &StatJob::slotFinished); Scheduler::cancelJob(job); // deletes the slave if not 0 }