fingerprint: handle failed dbus connection (#676)

This commit is contained in:
Maximilian Seidler 2025-02-05 09:36:31 +00:00 committed by GitHub
parent ec82da7108
commit ce750456f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -47,8 +47,15 @@ CFingerprint::~CFingerprint() {
}
void CFingerprint::init() {
m_sDBUSState.connection = sdbus::createSystemBusConnection();
m_sDBUSState.login = sdbus::createProxy(*m_sDBUSState.connection, sdbus::ServiceName{"org.freedesktop.login1"}, sdbus::ObjectPath{"/org/freedesktop/login1"});
try {
m_sDBUSState.connection = sdbus::createSystemBusConnection();
m_sDBUSState.login = sdbus::createProxy(*m_sDBUSState.connection, sdbus::ServiceName{"org.freedesktop.login1"}, sdbus::ObjectPath{"/org/freedesktop/login1"});
} catch (sdbus::Error& e) {
Debug::log(ERR, "fprint: Failed to setup dbus ({})", e.what());
m_sDBUSState.connection.reset();
return;
}
m_sDBUSState.login->getPropertyAsync("PreparingForSleep").onInterface(LOGIN_MANAGER).uponReplyInvoke([this](std::optional<sdbus::Error> e, sdbus::Variant preparingForSleep) {
if (e) {
Debug::log(WARN, "fprint: Failed getting value for PreparingForSleep: {}", e->what());