https://bugs.kde.org/show_bug.cgi?id=446272

            Bug ID: 446272
           Summary: KRun opens URLs twice due to XDG activation
                    integration breaking
                    ApplicationLauncherJob::waitForStarted
           Product: frameworks-kio
           Version: 5.88.0
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: kio-bugs-n...@kde.org
          Reporter: fab...@ritter-vogt.de
                CC: aleix...@kde.org, kdelibs-b...@kde.org
  Target Milestone: ---

Reproducer:

#include <QApplication>
#include <QDialog>
#include <KRun>

int main(int argc, char *argv[])
{
        QApplication app(argc, argv);
        QDialog dialog;
        dialog.show();
        new KRun(QUrl(app.arguments()[1]), NULL);
        return app.exec();
}

Run in a wayland session and pass a url, e.g. https://kde.org. The result is
that https://kde.org is opened twice, sometimes even in different
applications...

What happens is this:

KRun::init() does:

        if (d->runExternalBrowser(d->m_externalBrowser)) {
            return;
        }
        // Scan file to get more info

The issue is that runExternalBrowser fails, despite actually spawning the
process sucessfully, and so it goes into the fallback path in addition.

KRunPrivate::runExternalBrowser calls KRun::runApplication:

    KIO::ApplicationLauncherJob *job = new
KIO::ApplicationLauncherJob(servicePtr);
    job->setUrls(urls);
    ....
    job->start();
    job->waitForStarted();
    return job->error() ? 0 : job->pid();

This fails because job->waitForStarted(); does not wait for the XDG activation
token, and so the process wasn't started yet and doesn't have a pid set.

With a debug build of KIO, there's even an assert failure:

ASSERT failure in QVector<T>::at: "index out of range", file
/usr/include/qt5/QtCore/qvector.h, line 449

Thread 1 "kruntest" received signal SIGABRT, Aborted.
0x00007ffff5d1329c in __pthread_kill_implementation () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff5d1329c in __pthread_kill_implementation () from
/lib64/libc.so.6
#1  0x00007ffff5cc3366 in raise () from /lib64/libc.so.6
#2  0x00007ffff5cac7d3 in abort () from /lib64/libc.so.6
#3  0x00007ffff62fbfe7 in QMessageLogger::fatal(char const*, ...) const () from
/lib64/libQt5Core.so.5
#4  0x00007ffff62fb4ca in qt_assert_x(char const*, char const*, char const*,
int) () from /lib64/libQt5Core.so.5
#5  0x00007ffff6cea1c1 in QVector<long long>::at (this=0x75eaf0, i=0) at
/usr/include/qt5/QtCore/qvector.h:449
#6  0x00007ffff6ce74e1 in KIO::ApplicationLauncherJob::pid (this=0x767820) at
/home/fabian/kderepos/kio/src/gui/applicationlauncherjob.cpp:237
#7  0x00007ffff7eeb888 in KRun::runApplication (service=..., urls=QList<QUrl>
(size = 1) = {...}, window=0x0, flags=..., flags@entry=...,
suggestedFileName="", asn=...) at
/usr/src/debug/kio-5.88.0-1.1.x86_64/src/widgets/krun.cpp:294
#8  0x00007ffff7eec168 in KRunPrivate::runExternalBrowser
(_exec="vivaldi-stable.desktop", this=0x49bf70) at
/usr/include/qt5/QtCore/qshareddata.h:159
#9  KRun::init (this=0x745b60) at
/usr/src/debug/kio-5.88.0-1.1.x86_64/src/widgets/krun.cpp:427
#10 0x00007ffff6552043 in ?? () from /lib64/libQt5Core.so.5

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to