diff --git a/src/core/kcoredirlister.cpp b/src/core/kcoredirlister.cpp --- a/src/core/kcoredirlister.cpp +++ b/src/core/kcoredirlister.cpp @@ -1796,7 +1796,6 @@ KFileItem item(*it, jobUrl, delayedMimeTypes, true); const QString name = item.name(); - Q_ASSERT(!name.isEmpty()); // we duplicate the check for dotdot here, to avoid iterating over // all items again and checking in matchesFilter() that way. diff --git a/src/ioslaves/remote/remoteimpl.h b/src/ioslaves/remote/remoteimpl.h --- a/src/ioslaves/remote/remoteimpl.h +++ b/src/ioslaves/remote/remoteimpl.h @@ -44,7 +44,7 @@ private: bool findDirectory(const QString &filename, QString &directory) const; - void createEntry(KIO::UDSEntry &entry, const QString &directory, const QString &file) const; + bool createEntry(KIO::UDSEntry &entry, const QString &directory, const QString &file) const; }; #endif diff --git a/src/ioslaves/remote/remoteimpl.cpp b/src/ioslaves/remote/remoteimpl.cpp --- a/src/ioslaves/remote/remoteimpl.cpp +++ b/src/ioslaves/remote/remoteimpl.cpp @@ -53,17 +53,16 @@ continue; } - const QStringList filenames = dir.entryList(QDir::Files | QDir::Readable); + const QStringList filenames = dir.entryList({QStringLiteral("*.desktop")}, + QDir::Files | QDir::Readable); KIO::UDSEntry entry; QStringList::ConstIterator name = filenames.constBegin(); QStringList::ConstIterator endf = filenames.constEnd(); for (; name != endf; ++name) { - if (!names_found.contains(*name)) { - entry.clear(); - createEntry(entry, *dirpath, *name); + if (!names_found.contains(*name) && createEntry(entry, *dirpath, *name)) { list.append(entry); names_found.append(*name); } @@ -166,21 +165,25 @@ return url == QUrl(WIZARD_URL); } -void RemoteImpl::createEntry(KIO::UDSEntry &entry, const QString &directory, +bool RemoteImpl::createEntry(KIO::UDSEntry &entry, const QString &directory, const QString &file) const { qCDebug(KIOREMOTE_LOG) << "RemoteImpl::createEntry"; QString dir = directory; if (!dir.endsWith(QLatin1Char('/'))) { dir += QLatin1Char('/'); } + KDesktopFile desktop(dir + file); - qCDebug(KIOREMOTE_LOG) << "path = " << directory << file; + qCDebug(KIOREMOTE_LOG) << "path = " << directory << file << desktop.readName(); entry.clear(); + if (desktop.readName().isEmpty()) + return false; + QString new_filename = file; new_filename.truncate(file.length()-8); @@ -195,19 +198,16 @@ entry.insert(KIO::UDSEntry::UDS_ICON_NAME, icon); entry.insert(KIO::UDSEntry::UDS_LINK_DEST, desktop.readUrl()); entry.insert(KIO::UDSEntry::UDS_TARGET_URL, desktop.readUrl()); + return true; } bool RemoteImpl::statNetworkFolder(KIO::UDSEntry &entry, const QString &filename) const { qCDebug(KIOREMOTE_LOG) << "RemoteImpl::statNetworkFolder: " << filename; QString directory; - if (findDirectory(filename+".desktop", directory)) { - createEntry(entry, directory, filename+".desktop"); - return true; - } - - return false; + return findDirectory(filename+".desktop", directory) + && createEntry(entry, directory, filename+".desktop"); } bool RemoteImpl::deleteNetworkFolder(const QString &filename) const