mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kinit: do not attempt to start service if it is started and its X-DBUS-StartupType is set to unique
for Katana that does not do much tho, applications that have X-DBUS-StartupType set to Unique use KUniqueApplication which does the neccessary checks to make sure another instance is not started Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
705386b4e9
commit
ce33f0e615
1 changed files with 14 additions and 2 deletions
|
@ -244,6 +244,20 @@ int KLauncherAdaptor::start_service_by_desktop_path(const QString &serviceName,
|
|||
error = i18n("Invalid service path: %1", serviceName);
|
||||
return KLauncherAdaptor::ServiceError;
|
||||
}
|
||||
const KService::DBusStartupType dbusstartuptype = kservice->dbusStartupType();
|
||||
dbusServiceName = kservice->property(QString::fromLatin1("X-DBUS-ServiceName"), QVariant::String).toString();
|
||||
if (dbusstartuptype == KService::DBusUnique) {
|
||||
QDBusReply<bool> sessionreply = m_dbusconnectioninterface->isServiceRegistered(dbusServiceName);
|
||||
if (!sessionreply.isValid()) {
|
||||
sendSIFinish();
|
||||
error = i18n("Invalid D-Bus reply for: %1", dbusServiceName);
|
||||
return KLauncherAdaptor::DBusError;
|
||||
}
|
||||
if (sessionreply.value() == true) {
|
||||
kDebug() << "service already started" << dbusServiceName;
|
||||
return KLauncherAdaptor::NoError;
|
||||
}
|
||||
}
|
||||
if (urls.size() > 1 && !kservice->allowMultipleFiles()) {
|
||||
// TODO: start multiple instances for each URL
|
||||
error = i18n("Service does not support multiple files: %1", serviceName);
|
||||
|
@ -256,8 +270,6 @@ int KLauncherAdaptor::start_service_by_desktop_path(const QString &serviceName,
|
|||
}
|
||||
const QString program = programandargs.takeFirst();
|
||||
const QStringList programargs = programandargs;
|
||||
const KService::DBusStartupType dbusstartuptype = kservice->dbusStartupType();
|
||||
dbusServiceName = kservice->property(QString::fromLatin1("X-DBUS-ServiceName"), QVariant::String).toString();
|
||||
int result = kdeinit_exec(program, programargs, envs, startup_id, msg, dbusServiceName, error, pid);
|
||||
if (result != KLauncherAdaptor::NoError) {
|
||||
// sendSIFinish() is called on exec error
|
||||
|
|
Loading…
Add table
Reference in a new issue