X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/27e3907a3daf9a63d05c00a0ff746de6cfdf2bdf..e6c1b97d67f6b6c6d4ad935db14241b041b3fca4:/src/global.cpp diff --git a/src/global.cpp b/src/global.cpp index e7ff67d77..4547faced 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( @@ -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,7 +118,8 @@ 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);