plasma: warn when the KUser object is not valid in kill runner

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-19 01:13:35 +03:00
parent e0f5820d6b
commit a92fd69279
2 changed files with 8 additions and 16 deletions

View file

@ -88,7 +88,14 @@ void KillRunner::match(Plasma::RunnerContext &context)
const quint64 pid = process->pid;
const qlonglong uid = process->uid;
const QString user = getUserName(uid);
QString user;
KUser kuser(uid);
if (kuser.isValid()) {
user = kuser.loginName();
} else {
kWarning() << "No user with UID" << uid << "was found";
user = QLatin1String("root");
}
QVariantList data;
data << pid << user;
@ -156,14 +163,4 @@ QList<QAction*> KillRunner::actionsForMatch(const Plasma::QueryMatch &match)
return ret;
}
QString KillRunner::getUserName(qlonglong uid)
{
KUser user(uid);
if (user.isValid()) {
return user.loginName();
}
kDebug() << QString("No user with UID %1 was found").arg(uid);
return "root";//No user with UID uid was found, so root is used
}
#include "moc_killrunner.cpp"

View file

@ -41,11 +41,6 @@ public:
void reloadConfiguration();
private:
/** @param uid the uid of the user
* @return the username of the user with the UID uid
*/
QString getUserName(qlonglong uid);
/** The trigger word */
QString m_triggerWord;