Skip to content

Commit

Permalink
fix: upower module selection with multiple devices
Browse files Browse the repository at this point in the history
While looping over all the upower devices, the currently set device that will be rendered in the waybar, is overridden. Since the loop doesn't end when the device is found, the upDevice_ is overridden with NULL in the iteration for the next device.

Now we only override upDevice_ if the current device matches the constraints.

Fixes d2a719d ("Redo to minimize code duplication.")
Fixes #3267
  • Loading branch information
3u13r committed Aug 31, 2024
1 parent 5d184f7 commit cbae893
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/modules/upower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,11 @@ void UPower::setDisplayDevice() {
displayDevice = upDevice;
}
}
// Unref current upDevice
if (displayDevice.upDevice != NULL) g_object_unref(thisPtr->upDevice_.upDevice);
// Reassign new upDevice
thisPtr->upDevice_ = displayDevice;
// Unref current upDevice if it exists
if (displayDevice.upDevice != NULL) {
if(thisPtr->upDevice_.upDevice != NULL) g_object_unref(thisPtr->upDevice_.upDevice);
thisPtr->upDevice_ = displayDevice;
}
},
this);
}
Expand Down

0 comments on commit cbae893

Please sign in to comment.