Skip to content

Commit b2d11f9

Browse files
authoredFeb 5, 2025
Merge pull request #3919 from KasyanDiGris/master
Hide upower module when specified device disconnected
2 parents 0d5a4f8 + e32a678 commit b2d11f9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎src/modules/upower.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,12 @@ void UPower::resetDevices() {
358358
void UPower::setDisplayDevice() {
359359
std::lock_guard<std::mutex> guard{mutex_};
360360

361-
if (nativePath_.empty() && model_.empty()) {
362-
// Unref current upDevice
363-
if (upDevice_.upDevice != NULL) g_object_unref(upDevice_.upDevice);
361+
if (upDevice_.upDevice != NULL) {
362+
g_object_unref(upDevice_.upDevice);
363+
upDevice_.upDevice = NULL;
364+
}
364365

366+
if (nativePath_.empty() && model_.empty()) {
365367
upDevice_.upDevice = up_client_get_display_device(upClient_);
366368
getUpDeviceInfo(upDevice_);
367369
} else {
@@ -386,7 +388,6 @@ void UPower::setDisplayDevice() {
386388
}
387389
// Unref current upDevice if it exists
388390
if (displayDevice.upDevice != NULL) {
389-
if (thisPtr->upDevice_.upDevice != NULL) g_object_unref(thisPtr->upDevice_.upDevice);
390391
thisPtr->upDevice_ = displayDevice;
391392
}
392393
},

0 commit comments

Comments
 (0)