Skip to content

Commit c8a62c5

Browse files
committedNov 7, 2017
Fix bad logic in custom projections dialog (fixes #17258)
1 parent 108de77 commit c8a62c5

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed
 

‎src/app/qgscustomprojectiondialog.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,9 @@ void QgsCustomProjectionDialog::insertProjection( const QString &projectionAcro
339339
}
340340
}
341341

342-
bool QgsCustomProjectionDialog::saveCrs( QgsCoordinateReferenceSystem parameters, const QString &name, QString id, bool newEntry )
342+
bool QgsCustomProjectionDialog::saveCrs( QgsCoordinateReferenceSystem parameters, const QString &name, const QString &existingId, bool newEntry )
343343
{
344+
QString id = existingId;
344345
QString sql;
345346
int returnId;
346347
QString projectionAcronym = parameters.projectionAcronym();
@@ -504,37 +505,37 @@ void QgsCustomProjectionDialog::buttonBox_accepted()
504505
}
505506
}
506507
//Modify the CRS changed:
507-
bool save_success = true;
508+
bool saveSuccess = true;
508509
for ( int i = 0; i < mCustomCRSids.size(); ++i )
509510
{
510511
CRS.createFromProj4( mCustomCRSparameters[i] );
511512
//Test if we just added this CRS (if it has no existing ID)
512-
if ( !mCustomCRSids[i].isEmpty() )
513+
if ( mCustomCRSids[i].isEmpty() )
513514
{
514-
save_success &= saveCrs( CRS, mCustomCRSnames[i], QLatin1String( "" ), true );
515+
saveSuccess &= saveCrs( CRS, mCustomCRSnames[i], QString(), true );
515516
}
516517
else
517518
{
518519
if ( mExistingCRSnames[mCustomCRSids[i]] != mCustomCRSnames[i] || mExistingCRSparameters[mCustomCRSids[i]] != mCustomCRSparameters[i] )
519520
{
520-
save_success &= saveCrs( CRS, mCustomCRSnames[i], mCustomCRSids[i], false );
521+
saveSuccess &= saveCrs( CRS, mCustomCRSnames[i], mCustomCRSids[i], false );
521522
}
522523
}
523-
if ( ! save_success )
524+
if ( ! saveSuccess )
524525
{
525526
QgsDebugMsg( QString( "Error when saving CRS '%1'" ).arg( mCustomCRSnames[i] ) );
526527
}
527528
}
528529
QgsDebugMsg( "We remove the deleted CRS." );
529530
for ( int i = 0; i < mDeletedCRSs.size(); ++i )
530531
{
531-
save_success &= deleteCrs( mDeletedCRSs[i] );
532-
if ( ! save_success )
532+
saveSuccess &= deleteCrs( mDeletedCRSs[i] );
533+
if ( ! saveSuccess )
533534
{
534535
QgsDebugMsg( QString( "Problem for layer '%1'" ).arg( mCustomCRSparameters[i] ) );
535536
}
536537
}
537-
if ( save_success )
538+
if ( saveSuccess )
538539
{
539540
accept();
540541
}

‎src/app/qgscustomprojectiondialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class APP_EXPORT QgsCustomProjectionDialog : public QDialog, private Ui::QgsCust
4949
void populateList();
5050
QString quotedValue( QString value );
5151
bool deleteCrs( const QString &id );
52-
bool saveCrs( QgsCoordinateReferenceSystem parameters, const QString &name, QString id, bool newEntry );
52+
bool saveCrs( QgsCoordinateReferenceSystem parameters, const QString &name, const QString &id, bool newEntry );
5353
void insertProjection( const QString &projectionAcronym );
5454
void showHelp();
5555

0 commit comments

Comments
 (0)
Please sign in to comment.