diff --git a/src/gui/qgsmapcanvasannotationitem.cpp b/src/gui/qgsmapcanvasannotationitem.cpp index 14f565d13db..a3b4fe8eb78 100644 --- a/src/gui/qgsmapcanvasannotationitem.cpp +++ b/src/gui/qgsmapcanvasannotationitem.cpp @@ -287,6 +287,9 @@ double QgsMapCanvasAnnotationItem::scaledSymbolSize() const void QgsMapCanvasAnnotationItem::paint( QPainter *painter ) { + if ( !mAnnotation || !mAnnotation->isVisible() ) + return; + QgsRenderContext rc = QgsRenderContext::fromQPainter( painter ); rc.setFlag( QgsRenderContext::Antialiasing, true ); diff --git a/src/server/services/wms/qgswmsrenderer.cpp b/src/server/services/wms/qgswmsrenderer.cpp index 1a9340d3fff..861aa1d8c55 100644 --- a/src/server/services/wms/qgswmsrenderer.cpp +++ b/src/server/services/wms/qgswmsrenderer.cpp @@ -2806,11 +2806,14 @@ namespace QgsWms void QgsRenderer::annotationsRendering( QPainter *painter ) const { const QgsAnnotationManager *annotationManager = mProject->annotationManager(); - QList< QgsAnnotation * > annotations = annotationManager->annotations(); + const QList< QgsAnnotation * > annotations = annotationManager->annotations(); QgsRenderContext renderContext = QgsRenderContext::fromQPainter( painter ); - Q_FOREACH ( QgsAnnotation *annotation, annotations ) + for ( QgsAnnotation *annotation : annotations ) { + if ( !annotation || !annotation->isVisible() ) + continue; + annotation->render( renderContext ); } }