Skip to content

Commit

Permalink
Fix double ownership issue causing crash when deleting layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 7, 2017
1 parent 753f6f5 commit 6f59965
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/gui/layout/qgslayoutmousehandles.cpp
Expand Up @@ -44,12 +44,12 @@ QgsLayoutMouseHandles::QgsLayoutMouseHandles( QgsLayout *layout, QgsLayoutView *
//accept hover events, required for changing cursor to resize cursors
setAcceptHoverEvents( true );

mHorizontalSnapLine.reset( mView->createSnapLine() );
mHorizontalSnapLine = mView->createSnapLine();
mHorizontalSnapLine->hide();
layout->addItem( mHorizontalSnapLine.get() );
mVerticalSnapLine.reset( mView->createSnapLine() );
layout->addItem( mHorizontalSnapLine );
mVerticalSnapLine = mView->createSnapLine();
mVerticalSnapLine->hide();
layout->addItem( mVerticalSnapLine.get() );
layout->addItem( mVerticalSnapLine );
}

void QgsLayoutMouseHandles::paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
Expand Down Expand Up @@ -722,12 +722,12 @@ QPointF QgsLayoutMouseHandles::snapPoint( QPointF originalPoint, QgsLayoutMouseH
switch ( mode )
{
case Item:
snappedPoint = mLayout->snapper().snapRect( rect().translated( originalPoint ), mView->transform().m11(), snapped, snapHorizontal ? mHorizontalSnapLine.get() : nullptr,
snapVertical ? mVerticalSnapLine.get() : nullptr, &itemsToExclude ).topLeft();
snappedPoint = mLayout->snapper().snapRect( rect().translated( originalPoint ), mView->transform().m11(), snapped, snapHorizontal ? mHorizontalSnapLine : nullptr,
snapVertical ? mVerticalSnapLine : nullptr, &itemsToExclude ).topLeft();
break;
case Point:
snappedPoint = mLayout->snapper().snapPoint( originalPoint, mView->transform().m11(), snapped, snapHorizontal ? mHorizontalSnapLine.get() : nullptr,
snapVertical ? mVerticalSnapLine.get() : nullptr, &itemsToExclude );
snappedPoint = mLayout->snapper().snapPoint( originalPoint, mView->transform().m11(), snapped, snapHorizontal ? mHorizontalSnapLine : nullptr,
snapVertical ? mVerticalSnapLine : nullptr, &itemsToExclude );
break;
}

Expand Down
4 changes: 2 additions & 2 deletions src/gui/layout/qgslayoutmousehandles.h
Expand Up @@ -159,8 +159,8 @@ class GUI_EXPORT QgsLayoutMouseHandles: public QObject, public QGraphicsRectItem
bool mIsResizing = false;

//! Align snap lines
std::unique_ptr< QGraphicsLineItem > mHorizontalSnapLine;
std::unique_ptr< QGraphicsLineItem > mVerticalSnapLine;
QGraphicsLineItem *mHorizontalSnapLine = nullptr;
QGraphicsLineItem *mVerticalSnapLine = nullptr;

QSizeF mCursorOffset;

Expand Down

0 comments on commit 6f59965

Please sign in to comment.