Fix crash when reopening existing layouts

This commit is contained in:
Nyall Dawson 2017-12-05 14:04:41 +10:00
parent b6dab6ff48
commit ac6c131212
5 changed files with 13 additions and 0 deletions

View File

@ -25,6 +25,7 @@ class QgsLayoutViewToolSelect : QgsLayoutViewTool
%Docstring
Constructor for QgsLayoutViewToolSelect.
%End
~QgsLayoutViewToolSelect();
virtual void layoutPressEvent( QgsLayoutViewMouseEvent *event );

View File

@ -617,6 +617,7 @@ QgsLayout *QgsLayoutDesignerDialog::currentLayout()
void QgsLayoutDesignerDialog::setCurrentLayout( QgsLayout *layout )
{
layout->deselectAll();
mLayout = layout;
connect( mLayout, &QgsLayout::destroyed, this, &QgsLayoutDesignerDialog::close );

View File

@ -311,6 +311,9 @@ bool QgsLayoutMouseHandles::selectionRotation( double &rotation ) const
double QgsLayoutMouseHandles::rectHandlerBorderTolerance()
{
if ( !mView )
return 0;
//calculate size for resize handles
//get view scale factor
double viewScaleFactor = mView->transform().m11();

View File

@ -30,6 +30,12 @@ QgsLayoutViewToolSelect::QgsLayoutViewToolSelect( QgsLayoutView *view )
mRubberBand->setPen( QPen( QBrush( QColor( 254, 58, 29, 100 ) ), 0, Qt::DotLine ) );
}
QgsLayoutViewToolSelect::~QgsLayoutViewToolSelect()
{
if ( mMouseHandles )
mMouseHandles->deleteLater();
}
void QgsLayoutViewToolSelect::layoutPressEvent( QgsLayoutViewMouseEvent *event )
{
if ( mMouseHandles->shouldBlockEvent( event ) )
@ -276,6 +282,7 @@ QgsLayoutMouseHandles *QgsLayoutViewToolSelect::mouseHandles()
void QgsLayoutViewToolSelect::setLayout( QgsLayout *layout )
{
// existing handles are owned by previous layout
mMouseHandles->deleteLater();
//add mouse selection handles to layout, and initially hide
mMouseHandles = new QgsLayoutMouseHandles( layout, view() );

View File

@ -40,6 +40,7 @@ class GUI_EXPORT QgsLayoutViewToolSelect : public QgsLayoutViewTool
* Constructor for QgsLayoutViewToolSelect.
*/
QgsLayoutViewToolSelect( QgsLayoutView *view SIP_TRANSFERTHIS );
~QgsLayoutViewToolSelect();
void layoutPressEvent( QgsLayoutViewMouseEvent *event ) override;
void layoutMoveEvent( QgsLayoutViewMouseEvent *event ) override;