[libcamera-devel] [PATCH 3/8] android: CameraHalManager: Fix a function call of a moved Camera
Hirokazu Honda
hiroh at chromium.org
Tue Mar 23 02:42:21 CET 2021
This fixes a bug of calling Camera::id() of a moved Camera.
Signed-off-by: Hirokazu Honda <hiroh at chromium.org>
---
src/android/camera_hal_manager.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp
index fa398fea..df3f1cd2 100644
--- a/src/android/camera_hal_manager.cpp
+++ b/src/android/camera_hal_manager.cpp
@@ -95,7 +95,8 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)
* IDs starts from '0' for internal cameras and '1000' for external
* cameras.
*/
- auto iter = cameraIdsMap_.find(cam->id());
+ std::string cameraId = cam->id();
+ auto iter = cameraIdsMap_.find(cameraId);
if (iter != cameraIdsMap_.end()) {
id = iter->second;
} else {
@@ -117,12 +118,12 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)
std::unique_ptr<CameraDevice> camera = CameraDevice::create(id, std::move(cam));
int ret = camera->initialize();
if (ret) {
- LOG(HAL, Error) << "Failed to initialize camera: " << cam->id();
+ LOG(HAL, Error) << "Failed to initialize camera: " << cameraId;
return;
}
if (isCameraNew) {
- cameraIdsMap_.emplace(cam->id(), id);
+ cameraIdsMap_.emplace(cameraId, id);
if (isCameraExternal)
nextExternalCameraId_++;
--
2.31.0.rc2.261.g7f71774620-goog
More information about the libcamera-devel
mailing list