!173 fix:穿越后,插拔鼠标出现dinput crash

Merge pull request !173 from 李天刚/master
This commit is contained in:
openharmony_ci
2024-03-01 11:10:03 +00:00
committed by Gitee
+4 -2
View File
@@ -140,9 +140,10 @@ void InputHub::ScanAndRecordInputDevices()
openingDevices_.pop_back();
DHLOGI("Reporting device opened: path=%s, name=%s\n",
device->path.c_str(), device->identifier.name.c_str());
std::string devPath = device->path;
auto [dev_it, inserted] = devices_.insert_or_assign(device->path, std::move(device));
if (!inserted) {
DHLOGI("Device with this path %s exists, replaced. \n", device->path.c_str());
DHLOGI("Device with this path %s exists, replaced. \n", devPath.c_str());
}
}
}
@@ -387,9 +388,10 @@ size_t InputHub::DeviceIsExists(InputDeviceEvent *buffer, size_t bufferSize)
event->deviceInfo = device->identifier;
event += 1;
std::string devPath = device->path;
auto [dev_it, inserted] = devices_.insert_or_assign(device->path, std::move(device));
if (!inserted) {
DHLOGI("Device path %s exists, replaced.", device->path.c_str());
DHLOGI("Device path %s exists, replaced.", devPath.c_str());
}
if (capacity == 0) {
break;