solid: call power manager method synchronously

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-04-20 23:53:25 +03:00
parent 80c30dc690
commit 77fd0a79b1

View file

@ -140,8 +140,7 @@ int Solid::PowerManagement::beginSuppressingScreenPowerManagement(const QString&
message << QCoreApplication::applicationName(); message << QCoreApplication::applicationName();
message << reason; message << reason;
QDBusPendingReply<uint> ssReply = QDBusConnection::sessionBus().asyncCall(message); QDBusReply<uint> ssReply = QDBusConnection::sessionBus().call(message);
ssReply.waitForFinished();
if (ssReply.isValid()) { if (ssReply.isValid()) {
globalPowerManager()->screensaverCookies.append(ssReply.value()); globalPowerManager()->screensaverCookies.append(ssReply.value());
} }
@ -241,20 +240,16 @@ void Solid::PowerManagementPrivate::slotServiceRegistered(const QString &service
); );
// Load all the properties // Load all the properties
QDBusPendingReply<bool> suspendReply = managerIface->call("CanSuspend"); QDBusReply<bool> suspendReply = managerIface->call("CanSuspend");
suspendReply.waitForFinished();
slotCanSuspendChanged(suspendReply.isValid() ? suspendReply.value() : false); slotCanSuspendChanged(suspendReply.isValid() ? suspendReply.value() : false);
QDBusPendingReply<bool> hibernateReply = managerIface->call("CanHibernate"); QDBusReply<bool> hibernateReply = managerIface->call("CanHibernate");
hibernateReply.waitForFinished();
slotCanHibernateChanged(hibernateReply.isValid() ? hibernateReply.value() : false); slotCanHibernateChanged(hibernateReply.isValid() ? hibernateReply.value() : false);
QDBusPendingReply<bool> hybridSuspendReply = managerIface->call("CanHybridSuspend"); QDBusReply<bool> hybridSuspendReply = managerIface->call("CanHybridSuspend");
hybridSuspendReply.waitForFinished();
slotCanHybridSuspendChanged(hybridSuspendReply.isValid() ? hybridSuspendReply.value() : false); slotCanHybridSuspendChanged(hybridSuspendReply.isValid() ? hybridSuspendReply.value() : false);
QDBusPendingReply<bool> saveStatusReply = managerIface->call("GetPowerSaveStatus"); QDBusReply<bool> saveStatusReply = managerIface->call("GetPowerSaveStatus");
saveStatusReply.waitForFinished();
slotPowerSaveStatusChanged(saveStatusReply.isValid() ? saveStatusReply.value() : false); slotPowerSaveStatusChanged(saveStatusReply.isValid() ? saveStatusReply.value() : false);
connect(managerIface, SIGNAL(CanSuspendChanged(bool)), connect(managerIface, SIGNAL(CanSuspendChanged(bool)),