Commit a09fd32a authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Add a command line option to not quit on last client disconnect

Makes things simpler when developing since there's no need to constantly
restart ksystemstats.
parent dd8ebc83
......@@ -86,6 +86,11 @@ void KSysGuardDaemon::init(ReplaceIfRunning replaceIfRunning)
service->setExitValue(1);
}
void KSysGuardDaemon::setQuitOnLastClientDisconnect(bool quit)
{
m_quitOnLastClientDisconnect = quit;
}
void KSysGuardDaemon::loadProviders()
{
//instantiate all plugins
......@@ -233,7 +238,7 @@ KSysGuard::SensorProperty *KSysGuardDaemon::findSensor(const QString &path) cons
void KSysGuardDaemon::onServiceDisconnected(const QString &service)
{
delete m_clients.take(service);
if (m_clients.isEmpty()) {
if (m_clients.isEmpty() && m_quitOnLastClientDisconnect) {
QCoreApplication::quit();
};
}
......
......@@ -51,6 +51,8 @@ public:
void init(ReplaceIfRunning replaceIfRunning);
KSysGuard::SensorProperty *findSensor(const QString &path) const;
void setQuitOnLastClientDisconnect(bool quit);
public Q_SLOTS:
// DBus
KSysGuard::SensorInfoMap allSensors() const;
......@@ -81,4 +83,5 @@ private:
QHash<QString /*subscriber DBus base name*/, Client*> m_clients;
QHash<QString /*id*/, KSysGuard::SensorContainer *> m_containers;
QDBusServiceWatcher *m_serviceWatcher;
bool m_quitOnLastClientDisconnect = true;
};
......@@ -32,9 +32,12 @@ int main(int argc, char **argv)
QCommandLineParser parser;
parser.addOption(QCommandLineOption(QStringLiteral("replace"), QStringLiteral("Replace the running instance")));
parser.addOption({QStringLiteral("remain"), QStringLiteral("Do not quit when last client has disconnected")});
parser.addHelpOption();
parser.process(app);
KSysGuardDaemon d;
d.init(parser.isSet(QStringLiteral("replace")) ? KSysGuardDaemon::ReplaceIfRunning::Replace : KSysGuardDaemon::ReplaceIfRunning::DoNotReplace);
d.setQuitOnLastClientDisconnect(!parser.isSet(QStringLiteral("remain")));
app.exec();
}
Markdown is supported
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