Skip to content

Commit

Permalink
Fix setting the current GDAL profile options temporarily overwrites
Browse files Browse the repository at this point in the history
the definition of one of the stored GDAL profiles

Fixes qgis#41378
Fixes qgis#40235

(cherry picked from commit 7454a0e)
  • Loading branch information
nyalldawson committed Feb 19, 2021
1 parent 5267050 commit bb60092
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/gui/qgsrasterformatsaveoptionswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ void QgsRasterFormatSaveOptionsWidget::updateProfiles()

void QgsRasterFormatSaveOptionsWidget::updateOptions()
{
mBlockOptionUpdates++;
QString myOptions = mOptionsMap.value( currentProfileKey() );
QStringList myOptionsList = myOptions.trimmed().split( ' ', QString::SkipEmptyParts );

Expand Down Expand Up @@ -248,6 +249,7 @@ void QgsRasterFormatSaveOptionsWidget::updateOptions()
mOptionsLineEdit->setCursorPosition( 0 );
}

mBlockOptionUpdates--;
emit optionsChanged();
}

Expand Down Expand Up @@ -363,6 +365,9 @@ QString QgsRasterFormatSaveOptionsWidget::validateOptions( bool gui, bool report

void QgsRasterFormatSaveOptionsWidget::optionsTableChanged()
{
if ( mBlockOptionUpdates )
return;

QTableWidgetItem *key, *value;
QString options;
for ( int i = 0; i < mOptionsTable->rowCount(); i++ )
Expand Down Expand Up @@ -591,30 +596,32 @@ void QgsRasterFormatSaveOptionsWidget::showEvent( QShowEvent *event )

void QgsRasterFormatSaveOptionsWidget::setOptions( const QString &options )
{
mOptionsTable->blockSignals( true );
mBlockOptionUpdates++;
mOptionsTable->clearContents();

QStringList values;
QStringList optionsList = options.trimmed().split( ' ', QString::SkipEmptyParts );
const auto constOptionsList = optionsList;
for ( const QString &opt : constOptionsList )
const QStringList optionsList = options.trimmed().split( ' ', QString::SkipEmptyParts );
for ( const QString &opt : optionsList )
{
int rowCount = mOptionsTable->rowCount();
mOptionsTable->insertRow( rowCount );

values = opt.split( '=' );
const QStringList values = opt.split( '=' );
if ( values.count() == 2 )
{
QTableWidgetItem *nameItem = new QTableWidgetItem( values.at( 0 ) );
mOptionsTable->setItem( rowCount, 0, nameItem );
QTableWidgetItem *valueItem = new QTableWidgetItem( values.at( 1 ) );
mOptionsTable->setItem( rowCount, 0, valueItem );
mOptionsTable->setItem( rowCount, 1, valueItem );
}
}

// reset to no profile index, otherwise we are changing the definition of whichever profile
// is currently selected...
mProfileComboBox->setCurrentIndex( 0 );

mOptionsMap[ currentProfileKey()] = options.trimmed();
mOptionsLineEdit->setText( options.trimmed() );
mOptionsLineEdit->setCursorPosition( 0 );

mOptionsTable->blockSignals( false );
mBlockOptionUpdates--;
}
1 change: 1 addition & 0 deletions src/gui/qgsrasterformatsaveoptionswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class GUI_EXPORT QgsRasterFormatSaveOptionsWidget: public QWidget, private Ui::Q
static QMap< QString, QStringList > sBuiltinProfiles;
bool mPyramids = false;
QgsRaster::RasterPyramidsFormat mPyramidsFormat = QgsRaster::PyramidsGTiff;
int mBlockOptionUpdates = 0;

QString settingsKey( QString profile ) const SIP_FORCE;
QString currentProfileKey() const SIP_FORCE;
Expand Down

0 comments on commit bb60092

Please sign in to comment.