D23384: [WIP] Adding support for mounting KIOFuse URLs for applications that don't use KIO

Harald Sitter noreply at phabricator.kde.org
Mon Nov 18 10:35:46 GMT 2019


sitter added inline comments.

INLINE COMMENTS

> feverfew wrote in krun.cpp:598
> That's within the same loop though?
> 
> I explicitly want to change the QUrl in that list, so that I can simply return the same list without having to do a copy of it all.
> 
> I can't get this to work. I need to change the definition of the struct to be:
> 
> `struct MountRequest {QDBusReply<QString> reply; QUrl &url;};`
> 
> This doesn't compile because "is implicitly deleted because the default definition would be ill-formed"...

Can't reproduce with gcc.

  diff --git a/src/widgets/krun.cpp b/src/widgets/krun.cpp
  index c05875f7..2ea79257 100644
  --- a/src/widgets/krun.cpp
  +++ b/src/widgets/krun.cpp
  @@ -576,10 +576,9 @@ static QList<QUrl> resolveURLs(const QList<QUrl> &_urls, const KService &_servic
           org::kde::KIOFuse::VFS kiofuse_iface(QStringLiteral("org.kde.KIOFuse"),
                                                QStringLiteral("/org/kde/KIOFuse"),
                                                QDBusConnection::sessionBus());
  -        struct MountRequest { QDBusPendingReply<QString> reply; int urlIndex; };
  +        struct MountRequest { QDBusPendingReply<QString> reply; QUrl &url; };
           QVector<MountRequest> requests;
  -        for (int i = 0; i < urls.length(); ++i) {
  -            const QUrl url = urls[i];
  +        for (QUrl &url : urls) {
               if (KIO::DesktopExecParser::isProtocolInSupportedList(url, appSupportedProtocols))
                   continue;
               if (KProtocolInfo::protocolClass(url.scheme()) == QLatin1String(":local")) {
  @@ -588,7 +587,7 @@ static QList<QUrl> resolveURLs(const QList<QUrl> &_urls, const KService &_servic
                   if (job->exec()) { // ## nasty nested event loop!
                       const QUrl localURL = job->mostLocalUrl();
                       if (localURL != url) {
  -                        urls[i] = localURL;
  +                        url = localURL;
                           //qDebug() << "Changed to" << localURL;
                       // KIOFuse doesn't work too well with mtp/gdrive.
                       // @see https://invent.kde.org/kde/kio-fuse/issues/1 (GDrive)
  @@ -598,11 +597,11 @@ static QList<QUrl> resolveURLs(const QList<QUrl> &_urls, const KService &_servic
                               && url.scheme() != QLatin1String("gdrive")) {
                           // Can't convert...
                           // Lets try a KIOFuse mount instead.
  -                        requests.push_back({ kiofuse_iface.mountUrl(url.toString()), i });
  +                        requests.push_back({ kiofuse_iface.mountUrl(url.toString()), url });
                       }
                   }
               } else {
  -                requests.push_back({ kiofuse_iface.mountUrl(url.toString()), i });
  +                requests.push_back({ kiofuse_iface.mountUrl(url.toString()), url });
               }
           }
           // Doesn't matter that we've blocked here to process the replies.
  @@ -610,7 +609,7 @@ static QList<QUrl> resolveURLs(const QList<QUrl> &_urls, const KService &_servic
           for (auto request : requests) {
               request.reply.waitForFinished();
               if (!request.reply.isError()) {
  -                urls[request.urlIndex] = QUrl::fromLocalFile(request.reply.value());
  +                request.url = QUrl::fromLocalFile(request.reply.value());
               }
           }
       }

That said, I forgot about the second loop and I am not too sure that carrying the reference across two loops is all that nice to read anyway. Perhaps best wait for dfaure on this matter.

REPOSITORY
  R241 KIO

REVISION DETAIL
  https://phabricator.kde.org/D23384

To: feverfew, fvogt, davidedmundson, dfaure, ngraham
Cc: sitter, davidedmundson, kde-frameworks-devel, ngraham, LeGast00n, GB_2, michaelh, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20191118/be5550ea/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list