Fix ClusteredVectorLayer deadlock when its data source is non-empty while all elements are hidden
@@ -186,12 +186,9 @@ namespace carto {
return;
}
+ // Create singleton clusters
auto clusters = std::make_shared<std::vector<Cluster> >();
clusters->reserve(vectorElements.size() * 2);
- int singletonClusterCount = 0;
- int rootClusterIdx = -1;
- if (!vectorElements.empty()) {
- // Create singleton clusters
std::vector<int> clusterIdxs;
clusterIdxs.reserve(vectorElements.size());
for (const std::shared_ptr<VectorElement>& element : vectorElements) {
@@ -200,7 +197,7 @@ namespace carto {
clusterIdxs.push_back(clusterIdx);
}
}
- singletonClusterCount = static_cast<int>(clusters->size());
+ int singletonClusterCount = static_cast<int>(clusters->size());
// Check if we must recalculate clustering
{
@@ -227,6 +224,8 @@ namespace carto {
}
// Rebuild clusters, by doing bottom-up merging into a single cluster
+ int rootClusterIdx = -1;
+ if (!clusters->empty()) {
rootClusterIdx = mergeClusters(clusterIdxs.begin(), clusterIdxs.end(), *clusters, *projectionSurface, 1).front();
}
