Skip to content

Commit cb69c2d

Browse files
committed
service/upower: do not crash when trying to set power profile w/o ppd
1 parent 48a5638 commit cb69c2d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/dbus/properties.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ class DBusPropertyGroup: public QObject {
235235
void updateAllDirect();
236236
void updateAllViaGetAll();
237237
[[nodiscard]] QString toString() const;
238+
[[nodiscard]] bool isConnected() const { return this->interface; }
238239

239240
void pushPropertyUpdate(DBusPropertyCore* property);
240241
void requestPropertyUpdate(DBusPropertyCore* property);

src/services/upower/powerprofiles.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ void PowerProfiles::init() {
101101
}
102102

103103
void PowerProfiles::setProfile(PowerProfile::Enum profile) {
104+
if (!this->properties.isConnected()) {
105+
qCCritical(logPowerProfiles
106+
) << "Cannot set power profile: power-profiles-daemon not accessible or not running";
107+
return;
108+
}
109+
104110
if (profile == PowerProfile::Performance && !this->bHasPerformanceProfile) {
105111
qCCritical(logPowerProfiles
106112
) << "Cannot request performance profile as it is not present for this device.";

0 commit comments

Comments
 (0)