service/upower: do not crash when trying to set power profile w/o ppd

This commit is contained in:
outfoxxed 2025-05-13 17:07:51 -07:00
parent 48a56381a6
commit cb69c2d016
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 7 additions and 0 deletions

View file

@ -235,6 +235,7 @@ public:
void updateAllDirect();
void updateAllViaGetAll();
[[nodiscard]] QString toString() const;
[[nodiscard]] bool isConnected() const { return this->interface; }
void pushPropertyUpdate(DBusPropertyCore* property);
void requestPropertyUpdate(DBusPropertyCore* property);

View file

@ -101,6 +101,12 @@ void PowerProfiles::init() {
}
void PowerProfiles::setProfile(PowerProfile::Enum profile) {
if (!this->properties.isConnected()) {
qCCritical(logPowerProfiles
) << "Cannot set power profile: power-profiles-daemon not accessible or not running";
return;
}
if (profile == PowerProfile::Performance && !this->bHasPerformanceProfile) {
qCCritical(logPowerProfiles
) << "Cannot request performance profile as it is not present for this device.";