Skip to content

Commit 6a925f9

Browse files
committed
Don't set cleared data defined properties to NULL in expression editor
Fixes #18638
1 parent 3c08e2d commit 6a925f9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/gui/qgspropertyoverridebutton.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,11 @@ void QgsPropertyOverrideButton::showExpressionDialog()
591591
{
592592
QgsExpressionContext context = mExpressionContextGenerator ? mExpressionContextGenerator->createExpressionContext() : QgsExpressionContext();
593593

594-
QgsExpressionBuilderDialog d( const_cast<QgsVectorLayer *>( mVectorLayer ), mProperty.asExpression(), this, QStringLiteral( "generic" ), context );
594+
// build sensible initial expression text - see https://issues.qgis.org/issues/18638
595+
QString currentExpression = ( mProperty.propertyType() == QgsProperty::StaticProperty && !mProperty.staticValue().isValid() ) ? QString()
596+
: mProperty.asExpression();
597+
598+
QgsExpressionBuilderDialog d( const_cast<QgsVectorLayer *>( mVectorLayer ), currentExpression, this, QStringLiteral( "generic" ), context );
595599
if ( d.exec() == QDialog::Accepted )
596600
{
597601
mExpressionString = d.expressionText().trimmed();

0 commit comments

Comments
 (0)