Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 12, 2019
1 parent 69f45e3 commit 6648a95
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/expression/qgsexpressioncontextutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ QgsExpressionContextScope *QgsExpressionContextUtils::processingModelAlgorithmSc
modelPath = context.project()->projectStorage() ? context.project()->fileName() : context.project()->absoluteFilePath();
}

const QString modelFolder = QFileInfo( modelPath ).path();
const QString modelFolder = !modelPath.isEmpty() ? QFileInfo( modelPath ).path() : QString();
modelScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "model_path" ), QDir::toNativeSeparators( modelPath ), true ) );
modelScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "model_folder" ), QDir::toNativeSeparators( modelFolder ), true, true ) );
modelScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "model_name" ), model->displayName(), true ) );
Expand Down
4 changes: 2 additions & 2 deletions tests/src/analysis/testqgsprocessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6014,8 +6014,8 @@ void TestQgsProcessing::modelScope()
QCOMPARE( scope->variable( QStringLiteral( "model_group" ) ).toString(), QStringLiteral( "testGroup" ) );
QVERIFY( scope->hasVariable( QStringLiteral( "model_path" ) ) );
QVERIFY( scope->hasVariable( QStringLiteral( "model_folder" ) ) );
QVERIFY( scope->variable( QStringLiteral( "model_path" ) ).toString().isEmpty() );
QVERIFY( scope->variable( QStringLiteral( "model_folder" ) ).toString().isEmpty() );
QCOMPARE( scope->variable( QStringLiteral( "model_path" ) ).toString(), QString() );
QCOMPARE( scope->variable( QStringLiteral( "model_folder" ) ).toString(), QString() );

QgsProject p;
pc.setProject( &p );
Expand Down

0 comments on commit 6648a95

Please sign in to comment.