Commit 9e7931d8 authored by Julien Osman's avatar Julien Osman

BUG: Copy the maps before iterating over them and modifying them

parent c24fe741
...@@ -477,7 +477,8 @@ void ImageMetadata::compact() ...@@ -477,7 +477,8 @@ void ImageMetadata::compact()
bool compactVal; bool compactVal;
// TODO Compact the GeometryKeys when comparisons exists // TODO Compact the GeometryKeys when comparisons exists
// Compact NumericKeys // Compact NumericKeys
for (const auto& kv : this->Bands.front().NumericKeys) auto numKeys = this->Bands.front().NumericKeys;
for (const auto& kv : numKeys)
{ {
compactVal = true; compactVal = true;
auto bandIt = this->Bands.cbegin(); auto bandIt = this->Bands.cbegin();
...@@ -502,7 +503,8 @@ void ImageMetadata::compact() ...@@ -502,7 +503,8 @@ void ImageMetadata::compact()
} }
} }
// Compact StringKeys // Compact StringKeys
for (const auto& kv : this->Bands.front().StringKeys) auto strKeys = this->Bands.front().StringKeys;
for (const auto& kv : strKeys)
{ {
compactVal = true; compactVal = true;
auto bandIt = this->Bands.cbegin(); auto bandIt = this->Bands.cbegin();
...@@ -529,7 +531,8 @@ void ImageMetadata::compact() ...@@ -529,7 +531,8 @@ void ImageMetadata::compact()
// TODO Compact LUT1DKeys when comparisons exists // TODO Compact LUT1DKeys when comparisons exists
// TODO Compact LUT2DKeys when comparisons exists // TODO Compact LUT2DKeys when comparisons exists
// Compact TimeKeys // Compact TimeKeys
for (const auto& kv : this->Bands.front().TimeKeys) auto timeKeys = this->Bands.front().TimeKeys;
for (const auto& kv : timeKeys)
{ {
compactVal = true; compactVal = true;
auto bandIt = this->Bands.cbegin(); auto bandIt = this->Bands.cbegin();
...@@ -554,7 +557,8 @@ void ImageMetadata::compact() ...@@ -554,7 +557,8 @@ void ImageMetadata::compact()
} }
} }
// Compact ExtraKeys // Compact ExtraKeys
for (const auto& kv : this->Bands.front().ExtraKeys) auto extraKeys = this->Bands.front().ExtraKeys;
for (const auto& kv : extraKeys)
{ {
compactVal = true; compactVal = true;
auto bandIt = this->Bands.cbegin(); auto bandIt = this->Bands.cbegin();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment