@@ -1225,6 +1225,9 @@ bool QgsProcessingParameterDefinition::checkValueIsAcceptable( const QVariant &i
1225
1225
1226
1226
QString QgsProcessingParameterDefinition::valueAsPythonString ( const QVariant &value, QgsProcessingContext & ) const
1227
1227
{
1228
+ if ( !value.isValid () )
1229
+ return QStringLiteral ( " None" );
1230
+
1228
1231
if ( value.canConvert <QgsProperty>() )
1229
1232
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
1230
1233
@@ -1291,6 +1294,9 @@ QgsProcessingParameterDefinition *QgsProcessingParameterBoolean::clone() const
1291
1294
1292
1295
QString QgsProcessingParameterBoolean::valueAsPythonString ( const QVariant &val, QgsProcessingContext & ) const
1293
1296
{
1297
+ if ( !val.isValid () )
1298
+ return QStringLiteral ( " None" );
1299
+
1294
1300
if ( val.canConvert <QgsProperty>() )
1295
1301
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( val.value < QgsProperty >().asExpression () );
1296
1302
return val.toBool () ? QStringLiteral ( " True" ) : QStringLiteral ( " False" );
@@ -1344,6 +1350,9 @@ bool QgsProcessingParameterCrs::checkValueIsAcceptable( const QVariant &input, Q
1344
1350
1345
1351
QString QgsProcessingParameterCrs::valueAsPythonString ( const QVariant &value, QgsProcessingContext &context ) const
1346
1352
{
1353
+ if ( !value.isValid () )
1354
+ return QStringLiteral ( " None" );
1355
+
1347
1356
if ( value.canConvert <QgsProperty>() )
1348
1357
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
1349
1358
@@ -1405,6 +1414,9 @@ bool QgsProcessingParameterMapLayer::checkValueIsAcceptable( const QVariant &inp
1405
1414
1406
1415
QString QgsProcessingParameterMapLayer::valueAsPythonString ( const QVariant &val, QgsProcessingContext &context ) const
1407
1416
{
1417
+ if ( !val.isValid () )
1418
+ return QStringLiteral ( " None" );
1419
+
1408
1420
if ( val.canConvert <QgsProperty>() )
1409
1421
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( val.value < QgsProperty >().asExpression () );
1410
1422
@@ -1487,6 +1499,9 @@ bool QgsProcessingParameterExtent::checkValueIsAcceptable( const QVariant &input
1487
1499
1488
1500
QString QgsProcessingParameterExtent::valueAsPythonString ( const QVariant &value, QgsProcessingContext &context ) const
1489
1501
{
1502
+ if ( !value.isValid () )
1503
+ return QStringLiteral ( " None" );
1504
+
1490
1505
if ( value.canConvert <QgsProperty>() )
1491
1506
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
1492
1507
@@ -1574,6 +1589,9 @@ bool QgsProcessingParameterPoint::checkValueIsAcceptable( const QVariant &input,
1574
1589
1575
1590
QString QgsProcessingParameterPoint::valueAsPythonString ( const QVariant &value, QgsProcessingContext &context ) const
1576
1591
{
1592
+ if ( !value.isValid () )
1593
+ return QStringLiteral ( " None" );
1594
+
1577
1595
if ( value.canConvert <QgsProperty>() )
1578
1596
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
1579
1597
@@ -1714,6 +1732,9 @@ bool QgsProcessingParameterMatrix::checkValueIsAcceptable( const QVariant &input
1714
1732
1715
1733
QString QgsProcessingParameterMatrix::valueAsPythonString ( const QVariant &value, QgsProcessingContext &context ) const
1716
1734
{
1735
+ if ( !value.isValid () )
1736
+ return QStringLiteral ( " None" );
1737
+
1717
1738
if ( value.canConvert <QgsProperty>() )
1718
1739
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
1719
1740
@@ -1874,6 +1895,9 @@ bool QgsProcessingParameterMultipleLayers::checkValueIsAcceptable( const QVarian
1874
1895
1875
1896
QString QgsProcessingParameterMultipleLayers::valueAsPythonString ( const QVariant &value, QgsProcessingContext &context ) const
1876
1897
{
1898
+ if ( !value.isValid () )
1899
+ return QStringLiteral ( " None" );
1900
+
1877
1901
if ( value.canConvert <QgsProperty>() )
1878
1902
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
1879
1903
@@ -2025,6 +2049,9 @@ bool QgsProcessingParameterNumber::checkValueIsAcceptable( const QVariant &input
2025
2049
2026
2050
QString QgsProcessingParameterNumber::valueAsPythonString ( const QVariant &value, QgsProcessingContext & ) const
2027
2051
{
2052
+ if ( !value.isValid () )
2053
+ return QStringLiteral ( " None" );
2054
+
2028
2055
if ( value.canConvert <QgsProperty>() )
2029
2056
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
2030
2057
@@ -2155,6 +2182,9 @@ bool QgsProcessingParameterRange::checkValueIsAcceptable( const QVariant &input,
2155
2182
2156
2183
QString QgsProcessingParameterRange::valueAsPythonString ( const QVariant &value, QgsProcessingContext &context ) const
2157
2184
{
2185
+ if ( !value.isValid () )
2186
+ return QStringLiteral ( " None" );
2187
+
2158
2188
if ( value.canConvert <QgsProperty>() )
2159
2189
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
2160
2190
@@ -2241,6 +2271,9 @@ bool QgsProcessingParameterRasterLayer::checkValueIsAcceptable( const QVariant &
2241
2271
2242
2272
QString QgsProcessingParameterRasterLayer::valueAsPythonString ( const QVariant &val, QgsProcessingContext &context ) const
2243
2273
{
2274
+ if ( !val.isValid () )
2275
+ return QStringLiteral ( " None" );
2276
+
2244
2277
if ( val.canConvert <QgsProperty>() )
2245
2278
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( val.value < QgsProperty >().asExpression () );
2246
2279
@@ -2330,6 +2363,9 @@ bool QgsProcessingParameterEnum::checkValueIsAcceptable( const QVariant &input,
2330
2363
2331
2364
QString QgsProcessingParameterEnum::valueAsPythonString ( const QVariant &value, QgsProcessingContext & ) const
2332
2365
{
2366
+ if ( !value.isValid () )
2367
+ return QStringLiteral ( " None" );
2368
+
2333
2369
if ( value.canConvert <QgsProperty>() )
2334
2370
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
2335
2371
@@ -2443,6 +2479,9 @@ QgsProcessingParameterDefinition *QgsProcessingParameterString::clone() const
2443
2479
2444
2480
QString QgsProcessingParameterString::valueAsPythonString ( const QVariant &value, QgsProcessingContext & ) const
2445
2481
{
2482
+ if ( !value.isValid () )
2483
+ return QStringLiteral ( " None" );
2484
+
2446
2485
if ( value.canConvert <QgsProperty>() )
2447
2486
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
2448
2487
@@ -2525,6 +2564,9 @@ QgsProcessingParameterDefinition *QgsProcessingParameterExpression::clone() cons
2525
2564
2526
2565
QString QgsProcessingParameterExpression::valueAsPythonString ( const QVariant &value, QgsProcessingContext & ) const
2527
2566
{
2567
+ if ( !value.isValid () )
2568
+ return QStringLiteral ( " None" );
2569
+
2528
2570
if ( value.canConvert <QgsProperty>() )
2529
2571
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
2530
2572
@@ -2623,6 +2665,9 @@ bool QgsProcessingParameterVectorLayer::checkValueIsAcceptable( const QVariant &
2623
2665
2624
2666
QString QgsProcessingParameterVectorLayer::valueAsPythonString ( const QVariant &val, QgsProcessingContext &context ) const
2625
2667
{
2668
+ if ( !val.isValid () )
2669
+ return QStringLiteral ( " None" );
2670
+
2626
2671
if ( val.canConvert <QgsProperty>() )
2627
2672
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( val.value < QgsProperty >().asExpression () );
2628
2673
@@ -2723,6 +2768,9 @@ bool QgsProcessingParameterField::checkValueIsAcceptable( const QVariant &input,
2723
2768
2724
2769
QString QgsProcessingParameterField::valueAsPythonString ( const QVariant &value, QgsProcessingContext & ) const
2725
2770
{
2771
+ if ( !value.isValid () )
2772
+ return QStringLiteral ( " None" );
2773
+
2726
2774
if ( value.canConvert <QgsProperty>() )
2727
2775
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
2728
2776
@@ -2942,6 +2990,9 @@ bool QgsProcessingParameterFeatureSource::checkValueIsAcceptable( const QVariant
2942
2990
2943
2991
QString QgsProcessingParameterFeatureSource::valueAsPythonString ( const QVariant &value, QgsProcessingContext &context ) const
2944
2992
{
2993
+ if ( !value.isValid () )
2994
+ return QStringLiteral ( " None" );
2995
+
2945
2996
if ( value.canConvert <QgsProperty>() )
2946
2997
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
2947
2998
@@ -3120,6 +3171,9 @@ bool QgsProcessingParameterFeatureSink::checkValueIsAcceptable( const QVariant &
3120
3171
3121
3172
QString QgsProcessingParameterFeatureSink::valueAsPythonString ( const QVariant &value, QgsProcessingContext & ) const
3122
3173
{
3174
+ if ( !value.isValid () )
3175
+ return QStringLiteral ( " None" );
3176
+
3123
3177
if ( value.canConvert <QgsProperty>() )
3124
3178
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
3125
3179
@@ -3322,6 +3376,9 @@ bool QgsProcessingParameterRasterDestination::checkValueIsAcceptable( const QVar
3322
3376
3323
3377
QString QgsProcessingParameterRasterDestination::valueAsPythonString ( const QVariant &value, QgsProcessingContext & ) const
3324
3378
{
3379
+ if ( !value.isValid () )
3380
+ return QStringLiteral ( " None" );
3381
+
3325
3382
if ( value.canConvert <QgsProperty>() )
3326
3383
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
3327
3384
@@ -3415,6 +3472,9 @@ bool QgsProcessingParameterFileDestination::checkValueIsAcceptable( const QVaria
3415
3472
3416
3473
QString QgsProcessingParameterFileDestination::valueAsPythonString ( const QVariant &value, QgsProcessingContext & ) const
3417
3474
{
3475
+ if ( !value.isValid () )
3476
+ return QStringLiteral ( " None" );
3477
+
3418
3478
if ( value.canConvert <QgsProperty>() )
3419
3479
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
3420
3480
@@ -3628,6 +3688,9 @@ bool QgsProcessingParameterVectorDestination::checkValueIsAcceptable( const QVar
3628
3688
3629
3689
QString QgsProcessingParameterVectorDestination::valueAsPythonString ( const QVariant &value, QgsProcessingContext & ) const
3630
3690
{
3691
+ if ( !value.isValid () )
3692
+ return QStringLiteral ( " None" );
3693
+
3631
3694
if ( value.canConvert <QgsProperty>() )
3632
3695
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
3633
3696
@@ -3800,6 +3863,9 @@ bool QgsProcessingParameterBand::checkValueIsAcceptable( const QVariant &input,
3800
3863
3801
3864
QString QgsProcessingParameterBand::valueAsPythonString ( const QVariant &value, QgsProcessingContext & ) const
3802
3865
{
3866
+ if ( !value.isValid () )
3867
+ return QStringLiteral ( " None" );
3868
+
3803
3869
if ( value.canConvert <QgsProperty>() )
3804
3870
return QStringLiteral ( " QgsProperty.fromExpression('%1')" ).arg ( value.value < QgsProperty >().asExpression () );
3805
3871
0 commit comments