diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index a82cdec57..a684db62d 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -520,7 +520,7 @@ void Style::onLayerFilterChanged(Layer& layer) { void Style::onLayerVisibilityChanged(Layer& layer) { layer.accept(QueueSourceReloadVisitor { updateBatch }); - observer->onUpdate(Update::Layout); + observer->onUpdate(Update::RecalculateStyle | Update::Layout); } void Style::onLayerPaintPropertyChanged(Layer&) { diff --git a/test/style/style.cpp b/test/style/style.cpp index ff03e3c2c..41f12f6ff 100644 --- a/test/style/style.cpp +++ b/test/style/style.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -25,13 +26,25 @@ TEST(Style, UnusedSource) { style.cascade(now, MapMode::Still); style.recalculate(0, now, MapMode::Still); - Source *usedSource = style.getSource("usedsource"); + Source* usedSource = style.getSource("usedsource"); EXPECT_TRUE(usedSource); EXPECT_TRUE(usedSource->baseImpl->isLoaded()); - Source *unusedSource = style.getSource("unusedsource"); + Source* unusedSource = style.getSource("unusedsource"); EXPECT_TRUE(unusedSource); EXPECT_FALSE(unusedSource->baseImpl->isLoaded()); + + Layer* unusedLayer = style.getLayer("unusedlayervisibility"); + EXPECT_TRUE(unusedLayer); + + unusedLayer->setVisibility(mbgl::style::VisibilityType::Visible); + + style.relayout(); + EXPECT_FALSE(unusedSource->baseImpl->isLoaded()); + + // Style loads sources upon request when recalculating style. + style.recalculate(0, now, MapMode::Still); + EXPECT_TRUE(unusedSource->baseImpl->isLoaded()); } TEST(Style, UnusedSourceActiveViaClassUpdate) {