Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Forbid slashes in stored expression labels labels
... because labels become part of the QSettings key
  • Loading branch information
elpaso committed Dec 17, 2019
1 parent 403972d commit 0abb481
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/gui/qgsexpressionstoredialog.cpp
Expand Up @@ -17,9 +17,19 @@ QgsExpressionStoreDialog::QgsExpressionStoreDialog( const QString &label, const
saveBtn->setEnabled( false );
connect( mLabel, &QLineEdit::textChanged, this, [ = ]( const QString & text )
{
QString errorMessage;
if ( mExistingLabels.contains( text ) )
{
errorMessage = tr( "A stored expression with this name already exists" );
}
else if ( text.contains( '/' ) || text.contains( '\\' ) )
{
errorMessage = tr( "Labels cannot contain slashes (/ or \\)" );
}
if ( ! errorMessage.isEmpty() )
{
mValidationError->show();
mValidationError->setText( errorMessage );
saveBtn->setEnabled( false );
}
else
Expand All @@ -28,6 +38,9 @@ QgsExpressionStoreDialog::QgsExpressionStoreDialog( const QString &label, const
saveBtn->setEnabled( true );
}
} );
mLabel->setText( label );
// No slashes in labels!
QString labelFixed { label };
labelFixed.remove( '/' ).remove( '\\' );
mLabel->setText( labelFixed );
}

0 comments on commit 0abb481

Please sign in to comment.