[Kde-hardware-devel] PowerManager Library

Daniel Nicoletti dantti12 at gmail.com
Wed Jun 20 16:46:30 UTC 2012


Hi,

recently I reported a bug as the PowerManager library
was reporting the wrong PowerSaveStatus, Lukas took
a look, saw nothing wrong but proposed a patch, that well
sort of worked. After doing several tests with Apped KDED
module I realized the problem was when the DBus
interface was not available since Apper is loaded before
PM kded module.

So I decided to look at the code to find the issue, and
well there are actually some:
* QDBusPendingReply doesn't provide a default value
in case the call fails, which is why it returned true
when PM interface wasn't available, which in case the
best default would of course be false.
* If KDED dies for some reason (we can't think it must
work, bugs happen), it doesn't watch for service registration
so it won't update the client if the power save mode
has changed.

To the first I have two ways of fixing it, create a function
for cold plug which checks if the reply is valid otherwise
defaults to false. OR actually have the values at
the private class declared as QDBusPendingReply, which
when the user calls appShouldConserveResources() we
check if the reply is valid and if not we try getting the
value again, otherwise just return.

For the second it's a bit more complex, since the current
service watcher need to watch another path, and will
need to cold plug everything if the service is registered.

I started coding a cold plug function but well the code will
be quite big, so depending on the preferred approach I'll
do my codings

QDBusPendingReply<bool> psReply = managerIface.GetPowerSaveStatus();
    reply.waitForFinished();
    bool psValue = psReply.isValid() ? psReply.value() : false;
    if (psValue != powerSaveStatus) {
        slotPowerSaveStatusChanged(psValue);
    }

this is for only one of the values, there are more 2,
so well, the patch will be quite intrusive...


More information about the Kde-hardware-devel mailing list