fix: call "Subscribe" before connect to systemd

systemd will only send UnitNew/UnitRemoved after Subscribe called.
This commit is contained in:
black-desk 2023-08-28 15:56:43 +08:00
parent 8a662314f2
commit 02317993c8

View File

@ -6,6 +6,7 @@
#define SYSTEMDSIGNALDISPATCHER_H
#include "global.h"
#include <QDBusMessage>
class SystemdSignalDispatcher : public QObject
{
@ -29,6 +30,11 @@ private:
explicit SystemdSignalDispatcher(QObject *parent = nullptr)
: QObject(parent)
{
auto &con = ApplicationManager1DBus::instance().globalDestBus();
auto ret = con.call(QDBusMessage::createMethodCall(SystemdService, SystemdObjectPath, SystemdInterfaceName, "Subscribe"));
if (ret.type() == QDBusMessage::ErrorMessage) {
qFatal("%s", ret.errorMessage().toLocal8Bit().data());
}
if (!connectToSignals()) {
std::terminate();
}