Skip to content

Commit

Permalink
Fix crash when closing docked attribute table
Browse files Browse the repository at this point in the history
Fix #14909
Fix #15018

git bisect is your friend
  • Loading branch information
m-kuhn committed Jun 14, 2016
1 parent df6d2c6 commit a05b2ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/gui/attributetable/qgsattributetableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ void QgsAttributeTableView::setModel( QgsAttributeTableFilterModel* filterModel
connect( mFeatureSelectionModel, SIGNAL( requestRepaint( QModelIndexList ) ), this, SLOT( repaintRequested( QModelIndexList ) ) );
connect( mFeatureSelectionModel, SIGNAL( requestRepaint() ), this, SLOT( repaintRequested() ) );

delete mActionWidget;
mActionWidget = createActionWidget( 0 );
mActionWidget.reset( createActionWidget( 0 ) );
mActionWidget->setVisible( false );
updateActionImage( mActionWidget );
updateActionImage( mActionWidget.data() );
}
}

Expand All @@ -167,13 +166,13 @@ QWidget* QgsAttributeTableView::createActionWidget( QgsFeatureId fid )

if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
{
toolButton = new QToolButton( this );
toolButton = new QToolButton();
toolButton->setPopupMode( QToolButton::MenuButtonPopup );
container = toolButton;
}
else
{
container = new QWidget( this );
container = new QWidget();
container->setLayout( new QHBoxLayout() );
container->layout()->setMargin( 0 );
}
Expand Down Expand Up @@ -400,7 +399,7 @@ void QgsAttributeTableView::columnSizeChanged( int index, int oldWidth, int newW
if ( mFilterModel->actionColumnIndex() == index )
{
mActionWidget->resize( newWidth, mActionWidget->height() );
updateActionImage( mActionWidget );
updateActionImage( mActionWidget.data() );
}
emit columnResized( index, newWidth );
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/attributetable/qgsattributetableview.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class GUI_EXPORT QgsAttributeTableView : public QTableView
QMenu *mActionPopup;
int mRowSectionAnchor;
QItemSelectionModel::SelectionFlag mCtrlDragSelectionFlag;
QWidget* mActionWidget;
QScopedPointer<QWidget> mActionWidget;
};

#endif

4 comments on commit a05b2ad

@nirvn
Copy link
Contributor

@nirvn nirvn commented on a05b2ad Jun 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-kuhn I'm curious about this.... I can't see anything wrong with the original approach, so this is just working around a qt bug, right?

@m-kuhn
Copy link
Member Author

@m-kuhn m-kuhn commented on a05b2ad Jun 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I really don't understand what actually has gone wrong.
The combination of a child widget which is not rendered on the parent plus embedding in a dock somehow caused a double delete.

See also https://hub.qgis.org/issues/14909#note-7

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.