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

(cherry picked from commit 9a39f24)
  • Loading branch information
nyalldawson committed Dec 20, 2022
1 parent ba97310 commit 9916310
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/process/qgsprocess.cpp
Expand Up @@ -933,16 +933,15 @@ int QgsProcessingExec::execute( const QString &id, const QVariantMap &params, co
}
}

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() );
}

if ( !useJson )
Expand Down Expand Up @@ -990,7 +989,8 @@ int QgsProcessingExec::execute( const QString &id, const QVariantMap &params, co
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 9916310

Please sign in to comment.