Hide upower module when specified device disconnected
This commit is contained in:
@ -358,10 +358,12 @@ void UPower::resetDevices() {
|
||||
void UPower::setDisplayDevice() {
|
||||
std::lock_guard<std::mutex> guard{mutex_};
|
||||
|
||||
if (nativePath_.empty() && model_.empty()) {
|
||||
// Unref current upDevice
|
||||
if (upDevice_.upDevice != NULL) g_object_unref(upDevice_.upDevice);
|
||||
if (upDevice_.upDevice != NULL) {
|
||||
g_object_unref(upDevice_.upDevice);
|
||||
upDevice_.upDevice = NULL;
|
||||
}
|
||||
|
||||
if (nativePath_.empty() && model_.empty()) {
|
||||
upDevice_.upDevice = up_client_get_display_device(upClient_);
|
||||
getUpDeviceInfo(upDevice_);
|
||||
} else {
|
||||
@ -386,7 +388,6 @@ void UPower::setDisplayDevice() {
|
||||
}
|
||||
// Unref current upDevice if it exists
|
||||
if (displayDevice.upDevice != NULL) {
|
||||
if (thisPtr->upDevice_.upDevice != NULL) g_object_unref(thisPtr->upDevice_.upDevice);
|
||||
thisPtr->upDevice_ = displayDevice;
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user