@@ -778,11 +778,15 @@ QgsExpressionContextScope *QgsExpressionContextUtils::projectScope( const QgsPro
778
778
scope->setVariable ( it.key (), it.value (), true );
779
779
}
780
780
781
+ QString projectPath = project->absoluteFilePath ();
782
+ QString projectFolder = QFileInfo ( projectPath ).path ();
783
+ QString projectFilename = QFileInfo ( projectPath ).fileName ();
784
+
781
785
// add other known project variables
782
786
scope->addVariable ( QgsExpressionContextScope::StaticVariable ( QStringLiteral ( " project_title" ), project->title (), true , true ) );
783
- scope->addVariable ( QgsExpressionContextScope::StaticVariable ( QStringLiteral ( " project_path" ), QDir::toNativeSeparators ( project-> fileInfo (). filePath () ), true , true ) );
784
- scope->addVariable ( QgsExpressionContextScope::StaticVariable ( QStringLiteral ( " project_folder" ), QDir::toNativeSeparators ( project-> fileInfo (). dir (). path () ), true , true ) );
785
- scope->addVariable ( QgsExpressionContextScope::StaticVariable ( QStringLiteral ( " project_filename" ), project-> fileInfo (). fileName () , true , true ) );
787
+ scope->addVariable ( QgsExpressionContextScope::StaticVariable ( QStringLiteral ( " project_path" ), QDir::toNativeSeparators ( projectPath ), true , true ) );
788
+ scope->addVariable ( QgsExpressionContextScope::StaticVariable ( QStringLiteral ( " project_folder" ), QDir::toNativeSeparators ( projectFolder ), true , true ) );
789
+ scope->addVariable ( QgsExpressionContextScope::StaticVariable ( QStringLiteral ( " project_filename" ), projectFilename , true , true ) );
786
790
scope->addVariable ( QgsExpressionContextScope::StaticVariable ( QStringLiteral ( " project_home" ), QDir::toNativeSeparators ( project->homePath () ), true , true ) );
787
791
QgsCoordinateReferenceSystem projectCrs = project->crs ();
788
792
scope->addVariable ( QgsExpressionContextScope::StaticVariable ( QStringLiteral ( " project_crs" ), projectCrs.authid (), true , true ) );
0 commit comments