Skip to content
Permalink
Browse files

Use unique_ptr for mNumberSidesSpinBox

  • Loading branch information
lbartoletti committed Oct 3, 2017
1 parent 3e8403b commit b96282803b9d06025e67315746c7bab31a5df694
Showing with 5 additions and 6 deletions.
  1. +4 −5 src/app/qgsmaptooladdregularpolygon.cpp
  2. +1 −1 src/app/qgsmaptooladdregularpolygon.h
@@ -39,22 +39,21 @@ QgsMapToolAddRegularPolygon::~QgsMapToolAddRegularPolygon()
void QgsMapToolAddRegularPolygon::createNumberSidesSpinBox()
{
deleteNumberSidesSpinBox();
mNumberSidesSpinBox = new QSpinBox();
mNumberSidesSpinBox = std::unique_ptr<QSpinBox>( new QSpinBox() );
mNumberSidesSpinBox->setMaximum( 99999999 );
mNumberSidesSpinBox->setMinimum( 3 );
mNumberSidesSpinBox->setPrefix( tr( "Number of sides: " ) );
mNumberSidesSpinBox->setValue( mNumberSides );
QgisApp::instance()->addUserInputWidget( mNumberSidesSpinBox );
QgisApp::instance()->addUserInputWidget( mNumberSidesSpinBox.get() );
mNumberSidesSpinBox->setFocus( Qt::TabFocusReason );
}

void QgsMapToolAddRegularPolygon::deleteNumberSidesSpinBox()
{
if ( mNumberSidesSpinBox )
{
QgisApp::instance()->statusBarIface()->removeWidget( mNumberSidesSpinBox );
delete mNumberSidesSpinBox;
mNumberSidesSpinBox = nullptr;
QgisApp::instance()->statusBarIface()->removeWidget( mNumberSidesSpinBox.get() );
mNumberSidesSpinBox.reset( nullptr );
}
}

@@ -40,7 +40,7 @@ class QgsMapToolAddRegularPolygon: public QgsMapToolCapture
protected:
explicit QgsMapToolAddRegularPolygon( QgsMapCanvas *canvas ); //forbidden

QSpinBox *mNumberSidesSpinBox = nullptr;
std::unique_ptr<QSpinBox> mNumberSidesSpinBox;
int mNumberSides;

//! (re-)create the spin box to enter the number of sides

0 comments on commit b962828

Please sign in to comment.
You can’t perform that action at this time.