Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #38261 from m-kuhn/fix_annotation_item_reload
Fix crash on reloading project with annotation items
  • Loading branch information
m-kuhn committed Aug 14, 2020
2 parents 4f3a2f1 + 4615de0 commit 5114522
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/gui/qgsmapcanvasannotationitem.cpp
Expand Up @@ -47,7 +47,7 @@ QgsMapCanvasAnnotationItem::QgsMapCanvasAnnotationItem( QgsAnnotation *annotatio
connect( mAnnotation, &QgsAnnotation::mapLayerChanged, this, &QgsMapCanvasAnnotationItem::onCanvasLayersChanged );

//lifetime is tied to annotation!
connect( mAnnotation, &QgsAnnotation::destroyed, this, &QgsMapCanvasAnnotationItem::deleteLater );
connect( mAnnotation, &QgsAnnotation::destroyed, this, &QgsMapCanvasAnnotationItem::annotationDeleted );

updatePosition();
setFeatureForMapPosition();
Expand Down Expand Up @@ -126,6 +126,8 @@ void QgsMapCanvasAnnotationItem::updateBoundingRect()

void QgsMapCanvasAnnotationItem::onCanvasLayersChanged()
{
if ( !mAnnotation )
return;
if ( !mMapCanvas->annotationsVisible() )
{
setVisible( false );
Expand Down Expand Up @@ -174,6 +176,12 @@ void QgsMapCanvasAnnotationItem::setFeatureForMapPosition()
mAnnotation->setAssociatedFeature( currentFeature );
}

void QgsMapCanvasAnnotationItem::annotationDeleted()
{
mAnnotation = nullptr;
deleteLater();
}

void QgsMapCanvasAnnotationItem::drawSelectionBoxes( QPainter *p ) const
{
if ( !p )
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsmapcanvasannotationitem.h
Expand Up @@ -108,6 +108,8 @@ class GUI_EXPORT QgsMapCanvasAnnotationItem: public QObject, public QgsMapCanvas
//! Sets a feature for the current map position
void setFeatureForMapPosition();

void annotationDeleted();

private:

//! Draws selection handles around the item
Expand Down

0 comments on commit 5114522

Please sign in to comment.