Skip to content
Permalink
Browse files

address missing const and memory leaks

  • Loading branch information
3nids authored and nyalldawson committed Nov 30, 2017
1 parent fd3e85e commit 8ab658c5e9573551cf06c5e67fdff7fc066c1325
Showing with 29 additions and 29 deletions.
  1. +3 −4 src/app/qgisapp.cpp
  2. +23 −22 src/app/qgsdatumtransformtablewidget.cpp
  3. +3 −3 src/app/qgsdatumtransformtablewidget.h
@@ -7021,13 +7021,12 @@ void QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbologyOpt
{
//ask user about datum transformation
QgsSettings settings;
QgsDatumTransformDialog *dlg = new QgsDatumTransformDialog( vlayer->crs(), destCRS );
if ( dlg->availableTransformationCount() > 1 &&
QgsDatumTransformDialog dlg( vlayer->crs(), destCRS );
if ( dlg.availableTransformationCount() > 1 &&
settings.value( QStringLiteral( "Projections/showDatumTransformDialog" ), false ).toBool() )
{
dlg->exec();
dlg.exec();
}
delete dlg;
ct = QgsCoordinateTransform( vlayer->crs(), destCRS, QgsProject::instance() );
}

@@ -24,13 +24,13 @@ QgsDatumTransformTableModel::QgsDatumTransformTableModel( QObject *parent )
{
}

void QgsDatumTransformTableModel::setTransformContext( QgsCoordinateTransformContext &context )
void QgsDatumTransformTableModel::setTransformContext( const QgsCoordinateTransformContext &context )
{
mTransformContext = context;
reset();
}

void QgsDatumTransformTableModel::removeTransform( QModelIndexList indexes )
void QgsDatumTransformTableModel::removeTransform( const QModelIndexList &indexes )
{
QgsCoordinateReferenceSystem sourceCrs;
QgsCoordinateReferenceSystem destinationCrs;
@@ -188,10 +188,10 @@ QgsDatumTransformTableWidget::~QgsDatumTransformTableWidget()

void QgsDatumTransformTableWidget::addDatumTransform()
{
QgsDatumTransformDialog *dlg = new QgsDatumTransformDialog();
if ( dlg->exec() )
QgsDatumTransformDialog dlg;
if ( dlg.exec() )
{
QPair< QPair<QgsCoordinateReferenceSystem, int>, QPair<QgsCoordinateReferenceSystem, int > > dt = dlg->selectedDatumTransforms();
QPair< QPair<QgsCoordinateReferenceSystem, int>, QPair<QgsCoordinateReferenceSystem, int > > dt = dlg.selectedDatumTransforms();
QgsCoordinateTransformContext context = mModel->transformContext();
context.addSourceDestinationDatumTransform( dt.first.first, dt.second.first, dt.first.second, dt.second.second );
mModel->setTransformContext( context );
@@ -218,30 +218,31 @@ void QgsDatumTransformTableWidget::editDatumTransform()
int destinationTransform = -1;
for ( QModelIndexList::const_iterator it = selectedIndexes.constBegin(); it != selectedIndexes.constEnd(); it ++ )
{
if ( it->column() == QgsDatumTransformTableModel::SourceCrsColumn )
switch ( it->column() )
{
sourceCrs = QgsCoordinateReferenceSystem( mModel->data( *it, Qt::DisplayRole ).toString() );
}
if ( it->column() == QgsDatumTransformTableModel::DestinationCrsColumn )
{
destinationCrs = QgsCoordinateReferenceSystem( mModel->data( *it, Qt::DisplayRole ).toString() );
}
if ( it->column() == QgsDatumTransformTableModel::SourceTransformColumn )
{
sourceTransform = mModel->data( *it, Qt::UserRole ).toInt();
}
if ( it->column() == QgsDatumTransformTableModel::DestinationTransformColumn )
{
destinationTransform = mModel->data( *it, Qt::UserRole ).toInt();
case QgsDatumTransformTableModel::SourceCrsColumn:
sourceCrs = QgsCoordinateReferenceSystem( mModel->data( *it, Qt::DisplayRole ).toString() );
break;
case QgsDatumTransformTableModel::DestinationCrsColumn:
destinationCrs = QgsCoordinateReferenceSystem( mModel->data( *it, Qt::DisplayRole ).toString() );
break;
case QgsDatumTransformTableModel::SourceTransformColumn:
sourceTransform = mModel->data( *it, Qt::UserRole ).toInt();
break;
case QgsDatumTransformTableModel::DestinationTransformColumn:
destinationTransform = mModel->data( *it, Qt::UserRole ).toInt();
break;
default:
break;
}
}
if ( sourceCrs.isValid() && destinationCrs.isValid() &&
( sourceTransform != -1 || destinationTransform != -1 ) )
{
QgsDatumTransformDialog *dlg = new QgsDatumTransformDialog( sourceCrs, destinationCrs, qMakePair( sourceTransform, destinationTransform ) );
if ( dlg->exec() )
QgsDatumTransformDialog dlg( sourceCrs, destinationCrs, qMakePair( sourceTransform, destinationTransform ) );
if ( dlg.exec() )
{
QPair< QPair<QgsCoordinateReferenceSystem, int>, QPair<QgsCoordinateReferenceSystem, int > > dt = dlg->selectedDatumTransforms();
QPair< QPair<QgsCoordinateReferenceSystem, int>, QPair<QgsCoordinateReferenceSystem, int > > dt = dlg.selectedDatumTransforms();
QgsCoordinateTransformContext context = mModel->transformContext();
// QMap::insert takes care of replacing existing value
context.addSourceDestinationDatumTransform( sourceCrs, destinationCrs, dt.first.second, dt.second.second );
@@ -45,7 +45,7 @@ class APP_EXPORT QgsDatumTransformTableModel : public QAbstractTableModel

QgsDatumTransformTableModel( QObject *parent = nullptr );

void setTransformContext( QgsCoordinateTransformContext &context );
void setTransformContext( const QgsCoordinateTransformContext &context );

QgsCoordinateTransformContext transformContext() const
{
@@ -55,7 +55,7 @@ class APP_EXPORT QgsDatumTransformTableModel : public QAbstractTableModel
/**
* remove the transformation at given indexes
*/
void removeTransform( QModelIndexList indexes );
void removeTransform( const QModelIndexList &indexes );

int rowCount( const QModelIndex &parent ) const override;
int columnCount( const QModelIndex &parent ) const override;
@@ -76,7 +76,7 @@ class APP_EXPORT QgsDatumTransformTableWidget : public QWidget, private Ui::QgsD
explicit QgsDatumTransformTableWidget( QWidget *parent = 0 );
~QgsDatumTransformTableWidget();

void setTransformContext( QgsCoordinateTransformContext &context )
void setTransformContext( const QgsCoordinateTransformContext &context )
{
mModel->setTransformContext( context );
}

0 comments on commit 8ab658c

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