Code review comment for lp:~gerboland/qtmir/fix-lifecycle-exempt-keeps-wakelock

Revision history for this message
Gerry Boland (gerboland) wrote :

This unfortunately turned into a refactoring. The previous design relied on RAII, where the existence of the Wakelock object was supposed to correspond to a wakelock being held.

This design was flawed because of the asynchronous communication between powerd and qtmir. The problem case:
1. create a Wakelock object. This calls an async method of powerd to acquire a wakelock, which will eventually return a cookie.
2. destroy the Wakelock object. As no cookie saved, Wakelock has no cleanup to do
3. the promised cookie from powerd arrives, there's no Wakelock object to receive it. Cookie is lost, and wakelock remains held by powerd.

So I had to abandon the RAII design and instead have a single permanent Wakelock object which always stays connected to DBus.

To test this more thoroughly, am using the QDBusMock & QDBusTest tools.

« Back to merge proposal