Skip to content

Commit 3c76a07

Browse files
committedSep 25, 2017
Fix Coverity null pointer dereference warning
1 parent b0f27c5 commit 3c76a07

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed
 

‎src/core/processing/models/qgsprocessingmodelalgorithm.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
246246
continue;
247247

248248
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 ) );
250251

251252
const QgsProcessingModelChildAlgorithm &child = mChildAlgorithms[ childId ];
252253

@@ -255,7 +256,8 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
255256
<< createExpressionContextScopeForChildAlgorithm( childId, context, parameters, childResults );
256257

257258
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() ) );
259261

260262
QStringList params;
261263
for ( auto childParamIt = childParams.constBegin(); childParamIt != childParams.constEnd(); ++childParamIt )
@@ -264,8 +266,11 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
264266
child.algorithm()->parameterDefinition( childParamIt.key() )->valueAsPythonString( childParamIt.value(), context ) );
265267
}
266268

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+
}
269274

270275
QTime childTime;
271276
childTime.start();
@@ -277,7 +282,8 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
277282
if ( !ok )
278283
{
279284
QString error = QObject::tr( "Error encountered while running %1" ).arg( child.description() );
280-
feedback->reportError( error );
285+
if ( feedback )
286+
feedback->reportError( error );
281287
throw QgsProcessingException( error );
282288
}
283289
childResults.insert( childId, results );
@@ -293,13 +299,15 @@ QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap &pa
293299

294300
executed.insert( childId );
295301
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() ) );
297304
}
298305

299306
if ( feedback && feedback->isCanceled() )
300307
break;
301308
}
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 ) );
303311

304312
mResults = finalResults;
305313
return mResults;

0 commit comments

Comments
 (0)
Please sign in to comment.