@@ -246,7 +246,8 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
246
246
continue ;
247
247
248
248
executedAlg = true ;
249
- feedback->pushDebugInfo ( QObject::tr ( " Prepare algorithm: %1" ).arg ( childId ) );
249
+ if ( feedback )
250
+ feedback->pushDebugInfo ( QObject::tr ( " Prepare algorithm: %1" ).arg ( childId ) );
250
251
251
252
const QgsProcessingModelChildAlgorithm &child = mChildAlgorithms [ childId ];
252
253
@@ -255,7 +256,8 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
255
256
<< createExpressionContextScopeForChildAlgorithm ( childId, context, parameters, childResults );
256
257
257
258
QVariantMap childParams = parametersForChildAlgorithm ( child, parameters, childResults, expContext );
258
- feedback->setProgressText ( QObject::tr ( " Running %1 [%2/%3]" ).arg ( child.description () ).arg ( executed.count () + 1 ).arg ( toExecute.count () ) );
259
+ if ( feedback )
260
+ feedback->setProgressText ( QObject::tr ( " Running %1 [%2/%3]" ).arg ( child.description () ).arg ( executed.count () + 1 ).arg ( toExecute.count () ) );
259
261
260
262
QStringList params;
261
263
for ( auto childParamIt = childParams.constBegin (); childParamIt != childParams.constEnd (); ++childParamIt )
@@ -264,8 +266,11 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
264
266
child.algorithm ()->parameterDefinition ( childParamIt.key () )->valueAsPythonString ( childParamIt.value (), context ) );
265
267
}
266
268
267
- feedback->pushInfo ( QObject::tr ( " Input Parameters:" ) );
268
- feedback->pushCommandInfo ( QStringLiteral ( " { %1 }" ).arg ( params.join ( QStringLiteral ( " , " ) ) ) );
269
+ if ( feedback )
270
+ {
271
+ feedback->pushInfo ( QObject::tr ( " Input Parameters:" ) );
272
+ feedback->pushCommandInfo ( QStringLiteral ( " { %1 }" ).arg ( params.join ( QStringLiteral ( " , " ) ) ) );
273
+ }
269
274
270
275
QTime childTime;
271
276
childTime.start ();
@@ -277,7 +282,8 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
277
282
if ( !ok )
278
283
{
279
284
QString error = QObject::tr ( " Error encountered while running %1" ).arg ( child.description () );
280
- feedback->reportError ( error );
285
+ if ( feedback )
286
+ feedback->reportError ( error );
281
287
throw QgsProcessingException ( error );
282
288
}
283
289
childResults.insert ( childId, results );
@@ -293,13 +299,15 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
293
299
294
300
executed.insert ( childId );
295
301
modelFeedback.setCurrentStep ( executed.count () );
296
- feedback->pushInfo ( QObject::tr ( " OK. Execution took %1 s (%2 outputs)." ).arg ( childTime.elapsed () / 1000.0 ).arg ( results.count () ) );
302
+ if ( feedback )
303
+ feedback->pushInfo ( QObject::tr ( " OK. Execution took %1 s (%2 outputs)." ).arg ( childTime.elapsed () / 1000.0 ).arg ( results.count () ) );
297
304
}
298
305
299
306
if ( feedback && feedback->isCanceled () )
300
307
break ;
301
308
}
302
- feedback->pushDebugInfo ( QObject::tr ( " Model processed OK. Executed %1 algorithms total in %2 s." ).arg ( executed.count () ).arg ( totalTime.elapsed () / 1000.0 ) );
309
+ if ( feedback )
310
+ feedback->pushDebugInfo ( QObject::tr ( " Model processed OK. Executed %1 algorithms total in %2 s." ).arg ( executed.count () ).arg ( totalTime.elapsed () / 1000.0 ) );
303
311
304
312
mResults = finalResults;
305
313
return mResults ;
0 commit comments