Commit 3c48c539 authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈
Browse files

port to KIO::CommandLauncherJob

replaces the deprecated kdeinitExec.

this also allows us to get rid of the explicit dep on qtx11extras as the
new job encapsulates startupid handling
parent 9b1001b5
......@@ -51,8 +51,6 @@ find_package(
WindowSystem
SyntaxHighlighting
)
find_package(Qt5X11Extras ${QT_MIN_VERSION} CONFIG)
set_package_properties(Qt5X11Extras PROPERTIES TYPE RECOMMENDED PURPOSE "Recommended for better integration on X11.")
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050e00)
if(MINGW)
......
......@@ -2,9 +2,6 @@ include(CheckFunctionExists)
check_function_exists("strsignal" HAVE_STRSIGNAL)
check_function_exists("uname" HAVE_UNAME)
if(TARGET Qt::X11Extras)
set(HAVE_X11 TRUE)
endif()
if(NOT DEBUG_PACKAGE_INSTALLER_NAME)
set(DEBUG_PACKAGE_INSTALLER_NAME "installdbgsymbols.sh")
......@@ -103,6 +100,7 @@ target_link_libraries(
KF5::ConfigWidgets
KF5::JobWidgets
KF5::KIOCore
KF5::KIOGui
KF5::Crash
KF5::Completion
KF5::WindowSystem
......@@ -114,7 +112,6 @@ target_link_libraries(
KF5::SyntaxHighlighting # Backtrace Highlighting
drkonqi_backtrace_parser
qbugzilla
"$<$<BOOL:${HAVE_X11}>:Qt::X11Extras>"
)
if(WIN32)
......
#cmakedefine01 HAVE_STRSIGNAL
#cmakedefine01 HAVE_UNAME
#cmakedefine01 HAVE_X11
#define DEBUG_PACKAGE_INSTALLER_NAME "@DEBUG_PACKAGE_INSTALLER_NAME@"
......
......@@ -20,7 +20,7 @@
#endif
#endif
#include <KToolInvocation>
#include <KIO/CommandLauncherJob>
CrashedApplication::CrashedApplication(int pid,
int thread,
......@@ -187,15 +187,18 @@ void CrashedApplication::restart()
return;
}
// start the application via kdeinit, as it needs to have a pristine environment and
// KProcess::startDetached() can't start a new process with custom environment variables.
// start the application via CommandLauncherJob so it runs in a new cgroup if possible.
// if m_fakeBaseName is set, this means m_executable is the path to kdeinit4
// so we need to use the fakeBaseName to restart the app
const int ret = KToolInvocation::kdeinitExec(!m_fakeBaseName.isEmpty() ? m_fakeBaseName : m_executable.absoluteFilePath());
const bool success = (ret == 0);
m_restarted = success;
emit restarted(success);
auto job = new KIO::CommandLauncherJob(!m_fakeBaseName.isEmpty() ? m_fakeBaseName : m_executable.absoluteFilePath());
if (const QString &id = DrKonqi::startupId(); !id.isEmpty()) {
job->setStartupId(id.toUtf8());
}
connect(job, &KIO::CommandLauncherJob::result, this, [job, this] {
m_restarted = (job->error() == KJob::NoError);
Q_EMIT restarted(m_restarted);
});
job->start();
}
QString getSuggestedKCrashFilename(const CrashedApplication *app)
......
......@@ -295,6 +295,11 @@ void DrKonqi::setThread(int thread)
instance()->m_thread = thread;
}
void DrKonqi::setStartupId(const QString &startupId)
{
instance()->m_startupId = startupId;
}
int DrKonqi::signal()
{
return instance()->m_signal;
......@@ -387,4 +392,9 @@ const QString &DrKonqi::kdeBugzillaURL()
return url;
}
const QString &DrKonqi::startupId()
{
return instance()->m_startupId;
}
#include "drkonqi.moc"
......@@ -38,6 +38,7 @@ public:
static void setRestarted(bool restarted);
static void setKeepRunning(bool keepRunning);
static void setThread(int thread);
static void setStartupId(const QString &startupId);
static int signal();
static const QString &appName();
......@@ -53,6 +54,7 @@ public:
static int thread();
static bool ignoreQuality();
static const QString &kdeBugzillaURL();
static const QString &startupId();
private:
DrKonqi();
......@@ -74,6 +76,7 @@ private:
bool m_restarted;
bool m_keepRunning;
int m_thread;
QString m_startupId;
};
#endif
......@@ -25,9 +25,7 @@
#include <QDBusReply>
#include <config-drkonqi.h>
#if HAVE_X11
#include <QX11Info>
#endif
#ifdef Q_OS_MACOS
#include <KWindowSystem>
#endif
......@@ -184,15 +182,9 @@ int main(int argc, char *argv[])
DrKonqi::setRestarted(parser.isSet(restartedOption));
DrKonqi::setKeepRunning(parser.isSet(keepRunningOption));
DrKonqi::setThread(parser.value(threadOption).toInt());
DrKonqi::setStartupId(parser.value(startupIdOption));
auto forceDialog = parser.isSet(dialogOption);
#if HAVE_X11
const QString startupId = parser.value(startupIdOption);
if (!startupId.isEmpty()) {
QX11Info::setNextStartupId(startupId.toUtf8());
}
#endif
if (!DrKonqi::init()) {
return 1;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment