Skip to content

Commit

Permalink
Ensure qgis_process commands using project paths are correctly cleaned
Browse files Browse the repository at this point in the history
Fixes #50623
  • Loading branch information
nyalldawson committed Dec 7, 2022
1 parent 2ce0a26 commit 928689d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/process/qgsprocess.cpp
Expand Up @@ -1086,16 +1086,15 @@ int QgsProcessingExec::execute( const QString &inputId, const QVariantMap &param
}
}

std::unique_ptr< QgsProject > project;
QgsProject *project = nullptr;
if ( !projectPath.isEmpty() )
{
project = std::make_unique< QgsProject >();
project = QgsProject::instance();
if ( !project->read( projectPath ) )
{
std::cerr << QStringLiteral( "Could not load the QGIS project \"%1\"\n" ).arg( projectPath ).toLocal8Bit().constData();
return 1;
}
QgsProject::setInstance( project.get() );
json.insert( QStringLiteral( "project_path" ), projectPath );
}

Expand Down Expand Up @@ -1145,7 +1144,8 @@ int QgsProcessingExec::execute( const QString &inputId, const QVariantMap &param
context.setEllipsoid( ellipsoid );
context.setDistanceUnit( distanceUnit );
context.setAreaUnit( areaUnit );
context.setProject( project.get() );
if ( project )
context.setProject( project );
context.setLogLevel( logLevel );

const QgsProcessingParameterDefinitions defs = alg->parameterDefinitions();
Expand Down

0 comments on commit 928689d

Please sign in to comment.