Skip to content

Commit ac6c131

Browse files
committed
Fix crash when reopening existing layouts
1 parent b6dab6f commit ac6c131

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

python/gui/layout/qgslayoutviewtoolselect.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class QgsLayoutViewToolSelect : QgsLayoutViewTool
2525
%Docstring
2626
Constructor for QgsLayoutViewToolSelect.
2727
%End
28+
~QgsLayoutViewToolSelect();
2829

2930
virtual void layoutPressEvent( QgsLayoutViewMouseEvent *event );
3031

src/app/layout/qgslayoutdesignerdialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ QgsLayout *QgsLayoutDesignerDialog::currentLayout()
617617

618618
void QgsLayoutDesignerDialog::setCurrentLayout( QgsLayout *layout )
619619
{
620+
layout->deselectAll();
620621
mLayout = layout;
621622
connect( mLayout, &QgsLayout::destroyed, this, &QgsLayoutDesignerDialog::close );
622623

src/gui/layout/qgslayoutmousehandles.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ bool QgsLayoutMouseHandles::selectionRotation( double &rotation ) const
311311

312312
double QgsLayoutMouseHandles::rectHandlerBorderTolerance()
313313
{
314+
if ( !mView )
315+
return 0;
316+
314317
//calculate size for resize handles
315318
//get view scale factor
316319
double viewScaleFactor = mView->transform().m11();

src/gui/layout/qgslayoutviewtoolselect.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ QgsLayoutViewToolSelect::QgsLayoutViewToolSelect( QgsLayoutView *view )
3030
mRubberBand->setPen( QPen( QBrush( QColor( 254, 58, 29, 100 ) ), 0, Qt::DotLine ) );
3131
}
3232

33+
QgsLayoutViewToolSelect::~QgsLayoutViewToolSelect()
34+
{
35+
if ( mMouseHandles )
36+
mMouseHandles->deleteLater();
37+
}
38+
3339
void QgsLayoutViewToolSelect::layoutPressEvent( QgsLayoutViewMouseEvent *event )
3440
{
3541
if ( mMouseHandles->shouldBlockEvent( event ) )
@@ -276,6 +282,7 @@ QgsLayoutMouseHandles *QgsLayoutViewToolSelect::mouseHandles()
276282
void QgsLayoutViewToolSelect::setLayout( QgsLayout *layout )
277283
{
278284
// existing handles are owned by previous layout
285+
mMouseHandles->deleteLater();
279286

280287
//add mouse selection handles to layout, and initially hide
281288
mMouseHandles = new QgsLayoutMouseHandles( layout, view() );

src/gui/layout/qgslayoutviewtoolselect.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class GUI_EXPORT QgsLayoutViewToolSelect : public QgsLayoutViewTool
4040
* Constructor for QgsLayoutViewToolSelect.
4141
*/
4242
QgsLayoutViewToolSelect( QgsLayoutView *view SIP_TRANSFERTHIS );
43+
~QgsLayoutViewToolSelect();
4344

4445
void layoutPressEvent( QgsLayoutViewMouseEvent *event ) override;
4546
void layoutMoveEvent( QgsLayoutViewMouseEvent *event ) override;

0 commit comments

Comments
 (0)