Skip to content
Permalink
Browse files

Fix bad logic in custom projections dialog (fixes #17258)

  • Loading branch information
nyalldawson committed Nov 7, 2017
1 parent 108de77 commit c8a62c5c066d441f88e665f0801aab8c31322ff9
Showing with 11 additions and 10 deletions.
  1. +10 −9 src/app/qgscustomprojectiondialog.cpp
  2. +1 −1 src/app/qgscustomprojectiondialog.h
@@ -339,8 +339,9 @@ void QgsCustomProjectionDialog::insertProjection( const QString &projectionAcro
}
}

bool QgsCustomProjectionDialog::saveCrs( QgsCoordinateReferenceSystem parameters, const QString &name, QString id, bool newEntry )
bool QgsCustomProjectionDialog::saveCrs( QgsCoordinateReferenceSystem parameters, const QString &name, const QString &existingId, bool newEntry )
{
QString id = existingId;
QString sql;
int returnId;
QString projectionAcronym = parameters.projectionAcronym();
@@ -504,37 +505,37 @@ void QgsCustomProjectionDialog::buttonBox_accepted()
}
}
//Modify the CRS changed:
bool save_success = true;
bool saveSuccess = true;
for ( int i = 0; i < mCustomCRSids.size(); ++i )
{
CRS.createFromProj4( mCustomCRSparameters[i] );
//Test if we just added this CRS (if it has no existing ID)
if ( !mCustomCRSids[i].isEmpty() )
if ( mCustomCRSids[i].isEmpty() )
{
save_success &= saveCrs( CRS, mCustomCRSnames[i], QLatin1String( "" ), true );
saveSuccess &= saveCrs( CRS, mCustomCRSnames[i], QString(), true );
}
else
{
if ( mExistingCRSnames[mCustomCRSids[i]] != mCustomCRSnames[i] || mExistingCRSparameters[mCustomCRSids[i]] != mCustomCRSparameters[i] )
{
save_success &= saveCrs( CRS, mCustomCRSnames[i], mCustomCRSids[i], false );
saveSuccess &= saveCrs( CRS, mCustomCRSnames[i], mCustomCRSids[i], false );
}
}
if ( ! save_success )
if ( ! saveSuccess )
{
QgsDebugMsg( QString( "Error when saving CRS '%1'" ).arg( mCustomCRSnames[i] ) );
}
}
QgsDebugMsg( "We remove the deleted CRS." );
for ( int i = 0; i < mDeletedCRSs.size(); ++i )
{
save_success &= deleteCrs( mDeletedCRSs[i] );
if ( ! save_success )
saveSuccess &= deleteCrs( mDeletedCRSs[i] );
if ( ! saveSuccess )
{
QgsDebugMsg( QString( "Problem for layer '%1'" ).arg( mCustomCRSparameters[i] ) );
}
}
if ( save_success )
if ( saveSuccess )
{
accept();
}
@@ -49,7 +49,7 @@ class APP_EXPORT QgsCustomProjectionDialog : public QDialog, private Ui::QgsCust
void populateList();
QString quotedValue( QString value );
bool deleteCrs( const QString &id );
bool saveCrs( QgsCoordinateReferenceSystem parameters, const QString &name, QString id, bool newEntry );
bool saveCrs( QgsCoordinateReferenceSystem parameters, const QString &name, const QString &id, bool newEntry );
void insertProjection( const QString &projectionAcronym );
void showHelp();

0 comments on commit c8a62c5

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