Skip to content

Commit

Permalink
Don't leak memory in qgsnodeeditor delegates
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Dec 5, 2017
1 parent 2b3fbc7 commit efad2f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/app/nodetool/qgsnodeeditor.cpp
Expand Up @@ -297,11 +297,11 @@ QgsNodeEditor::QgsNodeEditor(

mTableView->setSelectionMode( QTableWidget::ExtendedSelection );
mTableView->setSelectionBehavior( QTableWidget::SelectRows );
mTableView->setItemDelegateForColumn( 0, new CoordinateItemDelegate() );
mTableView->setItemDelegateForColumn( 1, new CoordinateItemDelegate() );
mTableView->setItemDelegateForColumn( 2, new CoordinateItemDelegate() );
mTableView->setItemDelegateForColumn( 3, new CoordinateItemDelegate() );
mTableView->setItemDelegateForColumn( 4, new CoordinateItemDelegate() );
mTableView->setItemDelegateForColumn( 0, new CoordinateItemDelegate( this ) );
mTableView->setItemDelegateForColumn( 1, new CoordinateItemDelegate( this ) );
mTableView->setItemDelegateForColumn( 2, new CoordinateItemDelegate( this ) );
mTableView->setItemDelegateForColumn( 3, new CoordinateItemDelegate( this ) );
mTableView->setItemDelegateForColumn( 4, new CoordinateItemDelegate( this ) );

setWidget( mTableView );

Expand Down Expand Up @@ -396,6 +396,12 @@ void QgsNodeEditor::keyPressEvent( QKeyEvent *e )
// CoordinateItemDelegate
//

CoordinateItemDelegate::CoordinateItemDelegate( QObject *parent )
: QStyledItemDelegate( parent )
{

}

QString CoordinateItemDelegate::displayText( const QVariant &value, const QLocale &locale ) const
{
return locale.toString( value.toDouble(), 'f', 4 );
Expand Down
3 changes: 3 additions & 0 deletions src/app/nodetool/qgsnodeeditor.h
Expand Up @@ -107,6 +107,9 @@ class CoordinateItemDelegate : public QStyledItemDelegate
Q_OBJECT

public:

explicit CoordinateItemDelegate( QObject *parent = nullptr );

QString displayText( const QVariant &value, const QLocale &locale ) const override;

protected:
Expand Down

0 comments on commit efad2f6

Please sign in to comment.