Reduce scope of temp camera file

This commit is contained in:
Ingvar Stepanyan
2021-07-21 14:14:58 +00:00
parent 3b85b63d20
commit 5e54c25c55

View File

@@ -131,6 +131,9 @@ class Context {
val captureImageAsFile() { val captureImageAsFile() {
return gpp_rethrow([=]() { return gpp_rethrow([=]() {
auto &file = get_file();
{
struct TempCameraFile { struct TempCameraFile {
Camera &camera; Camera &camera;
GPContext &context; GPContext &context;
@@ -152,10 +155,10 @@ class Context {
gpp_try(gp_camera_capture(camera.get(), GP_CAPTURE_IMAGE, gpp_try(gp_camera_capture(camera.get(), GP_CAPTURE_IMAGE,
&camera_file.path, context.get())); &camera_file.path, context.get()));
auto &file = get_file();
gpp_try(gp_camera_file_get(camera.get(), camera_file.path.folder, gpp_try(gp_camera_file_get(camera.get(), camera_file.path.folder,
camera_file.path.name, GP_FILE_TYPE_NORMAL, camera_file.path.name, GP_FILE_TYPE_NORMAL,
&file, context.get())); &file, context.get()));
}
gpp_try(gp_file_set_name(&file, "image.")); gpp_try(gp_file_set_name(&file, "image."));
gpp_try(gp_file_adjust_name_for_mime_type(&file)); gpp_try(gp_file_adjust_name_for_mime_type(&file));