From 3ce614962fba9cd629557b1a196a717610d06cbc Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Sat, 9 Nov 2024 14:04:42 +0100 Subject: [PATCH] grid: only use mutexes when multithreading support is enabled (#1377) --- libheif/image-items/grid.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libheif/image-items/grid.cc b/libheif/image-items/grid.cc index 2bd3f1d183..4d765613c2 100644 --- a/libheif/image-items/grid.cc +++ b/libheif/image-items/grid.cc @@ -445,9 +445,11 @@ Error ImageItem_Grid::decode_and_paste_tile_image(heif_item_id tileID, uint32_t // --- generate the image canvas for combining all the tiles - if (!inout_image) { // this if avoids that we normally have to lock a mutex + if (!inout_image) { // this avoids that we normally have to lock a mutex +#if ENABLE_MULTITHREADING_SUPPORT static std::mutex createImageMutex; std::lock_guard lock(createImageMutex); +#endif if (!inout_image) { inout_image = std::make_shared(); @@ -479,8 +481,10 @@ Error ImageItem_Grid::decode_and_paste_tile_image(heif_item_id tileID, uint32_t inout_image->copy_image_to(tile_img, x0, y0); if (options.on_progress) { +#if ENABLE_MULTITHREADING_SUPPORT static std::mutex progressMutex; std::lock_guard lock(progressMutex); +#endif options.on_progress(heif_progress_step_total, ++progress_counter, options.progress_user_data); }