diff --git a/src/core/symbology/qgslinesymbollayer.cpp b/src/core/symbology/qgslinesymbollayer.cpp index 2e2ef43eae38..2bf7f3b0af7e 100644 --- a/src/core/symbology/qgslinesymbollayer.cpp +++ b/src/core/symbology/qgslinesymbollayer.cpp @@ -1536,8 +1536,10 @@ bool QgsTemplatedLineSymbolLayerBase::canCauseArtifactsBetweenAdjacentTiles() co || ( mPlacements & Qgis::MarkerLinePlacement::SegmentCenter ); } -void QgsTemplatedLineSymbolLayerBase::startFeatureRender( const QgsFeature &, QgsRenderContext & ) +void QgsTemplatedLineSymbolLayerBase::startFeatureRender( const QgsFeature &, QgsRenderContext &context ) { + installMasks( context, true ); + mRenderingFeature = true; mHasRenderedFirstPart = false; } @@ -4100,4 +4102,3 @@ Qgis::RenderUnit QgsFilledLineSymbolLayer::outputUnit() const } return Qgis::RenderUnit::Unknown; } - diff --git a/tests/src/python/test_selective_masking.py b/tests/src/python/test_selective_masking.py index 0531dca8cc55..97f97c0d02e3 100644 --- a/tests/src/python/test_selective_masking.py +++ b/tests/src/python/test_selective_masking.py @@ -26,13 +26,16 @@ QgsLayoutItemMap, QgsLayoutItemPage, QgsLayoutSize, + QgsLineSymbol, QgsMapRendererCache, QgsMapRendererCustomPainterJob, QgsMapRendererParallelJob, QgsMapRendererSequentialJob, QgsMapSettings, + QgsMarkerLineSymbolLayer, QgsMarkerSymbol, QgsMaskMarkerSymbolLayer, + QgsNullSymbolRenderer, QgsOuterGlowEffect, QgsPalLayerSettings, QgsPathResolver, @@ -1349,6 +1352,30 @@ def test_layout_export_svg_marker_masking(self): # no rasters self.check_layout_export("layout_export_svg_marker_masking", 0, [self.points_layer, self.lines_layer]) + def test_markerline_masked(self): + """ + Test a layout export where a QgsMarkerLineSymbolLayer is masked + """ + + sl = QgsMarkerLineSymbolLayer(True, 7) + circle_symbol = QgsMarkerSymbol.createSimple({'size': '3'}) + sl.setSubSymbol(circle_symbol) + + self.lines_layer.setRenderer(QgsSingleSymbolRenderer(QgsLineSymbol([sl]))) + self.polys_layer.setRenderer(QgsNullSymbolRenderer()) + + label_settings = self.polys_layer.labeling().settings() + fmt = label_settings.format() + # enable a mask + fmt.mask().setEnabled(True) + fmt.mask().setSize(4.0) + # and mask other symbol layers underneath + fmt.mask().setMaskedSymbolLayers([QgsSymbolLayerReference(self.lines_layer.id(), sl.id())]) + label_settings.setFormat(fmt) + self.polys_layer.labeling().setSettings(label_settings) + + self.check_layout_export("layout_export_markerline_masked", 0, [self.polys_layer, self.lines_layer]) + if __name__ == '__main__': start_app() diff --git a/tests/testdata/control_images/selective_masking/layout_export_markerline_masked/layout_export_markerline_masked.png b/tests/testdata/control_images/selective_masking/layout_export_markerline_masked/layout_export_markerline_masked.png new file mode 100644 index 000000000000..fc57d6cac9ff Binary files /dev/null and b/tests/testdata/control_images/selective_masking/layout_export_markerline_masked/layout_export_markerline_masked.png differ