X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/27e3907a3daf9a63d05c00a0ff746de6cfdf2bdf..2de943fbe452db02e882754e67863aa6600d2f8d:/src/global.cpp diff --git a/src/global.cpp b/src/global.cpp index e7ff67d77..58997ec46 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -70,10 +70,10 @@ void Dolphin::openNewWindow(const QList &urls, QWidget *window, const Open ); } -bool Dolphin::attachToExistingInstance(const QList& urls, bool openFiles, bool splitView, const QString& preferredService) +bool Dolphin::attachToExistingInstance(const QList& inputUrls, bool openFiles, bool splitView, const QString& preferredService) { - if (KWindowSystem::isPlatformWayland()) { - // TODO: once Wayland clients can raise or activate themselves remove this conditional + // TODO: once Wayland clients can raise or activate themselves remove check from conditional + if (KWindowSystem::isPlatformWayland() || inputUrls.isEmpty() || !GeneralSettings::openExternallyCalledFolderInNewTab()) { return false; } @@ -81,7 +81,8 @@ bool Dolphin::attachToExistingInstance(const QList& urls, bool openFiles, // Don't match the service without trailing "-" (unique instance) const QString pattern = QStringLiteral("org.kde.dolphin-"); - const QString myPid = QString::number(QCoreApplication::applicationPid()); + // Don't match the pid without leading "-" + const QString myPid = QStringLiteral("-") + QString::number(QCoreApplication::applicationPid()); QVector, QStringList>> dolphinServices; if (!preferredService.isEmpty()) { QSharedPointer preferred( @@ -90,7 +91,7 @@ bool Dolphin::attachToExistingInstance(const QList& urls, bool openFiles, QStringLiteral("org.kde.dolphin.MainWindow")) ); if (preferred->isValid()) { - dolphinServices.append(qMakePair(preferred, QStringList() )); + dolphinServices.append(qMakePair(preferred, QStringList())); } } @@ -103,7 +104,7 @@ bool Dolphin::attachToExistingInstance(const QList& urls, bool openFiles, QStringLiteral("/dolphin/Dolphin_1"), QStringLiteral("org.kde.dolphin.MainWindow")) ); - if (!instance->isValid()) { + if (!instance->isValid() || instance->lastError().isValid()) { continue; } dolphinServices.append(qMakePair(instance, QStringList())); @@ -117,14 +118,15 @@ bool Dolphin::attachToExistingInstance(const QList& urls, bool openFiles, QStringList newUrls; // check to see if any instances already have any of the given URLs open - for (const QString& url : QUrl::toStringList(urls)) { + const auto urls = QUrl::toStringList(inputUrls); + for (const QString& url : urls) { bool urlFound = false; for (auto& service: dolphinServices) { QDBusReply isUrlOpen = service.first->call(QStringLiteral("isUrlOpen"), url); if (isUrlOpen.isValid() && isUrlOpen.value()) { - service.second.append(url); - urlFound = true; - break; + service.second.append(url); + urlFound = true; + break; } } if (!urlFound) {